Bug 1850307 - Avoid truncation in TestSprintfLiteral.cpp. r=nika

Clang trunk started to warn about uses of snprintf that always lead to
truncation. The warning is hit in the test, but it's not really an
interesting part of the test, so prevent clang from warning by making
the format string smaller.

Differential Revision: https://phabricator.services.mozilla.com/D186990
This commit is contained in:
Mike Hommey 2023-08-28 20:53:30 +00:00
Родитель f3ccf4e652
Коммит 71ac4d413d
1 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@ -11,13 +11,13 @@ void bad() {
void ok() {
char x[100];
int y;
snprintf(x, sizeof(y), "what");
snprintf(x, sizeof(y), "foo");
snprintf(x, 50, "what");
snprintf(x, 50, "foo");
int nothundred = 100;
nothundred = 99;
snprintf(x, nothundred, "what");
snprintf(x, nothundred, "foo");
}
void vargs_bad(va_list args) {
@ -31,11 +31,11 @@ void vargs_bad(va_list args) {
void vargs_good(va_list args) {
char x[100];
int y;
vsnprintf(x, sizeof(y), "what", args);
vsnprintf(x, sizeof(y), "foo", args);
vsnprintf(x, 50, "what", args);
vsnprintf(x, 50, "foo", args);
int nothundred = 100;
nothundred = 99;
vsnprintf(x, nothundred, "what", args);
vsnprintf(x, nothundred, "foo", args);
}