зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
f3ccf4e652
Коммит
71ac4d413d
|
@ -11,13 +11,13 @@ void bad() {
|
||||||
void ok() {
|
void ok() {
|
||||||
char x[100];
|
char x[100];
|
||||||
int y;
|
int y;
|
||||||
snprintf(x, sizeof(y), "what");
|
snprintf(x, sizeof(y), "foo");
|
||||||
|
|
||||||
snprintf(x, 50, "what");
|
snprintf(x, 50, "foo");
|
||||||
|
|
||||||
int nothundred = 100;
|
int nothundred = 100;
|
||||||
nothundred = 99;
|
nothundred = 99;
|
||||||
snprintf(x, nothundred, "what");
|
snprintf(x, nothundred, "foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
void vargs_bad(va_list args) {
|
void vargs_bad(va_list args) {
|
||||||
|
@ -31,11 +31,11 @@ void vargs_bad(va_list args) {
|
||||||
void vargs_good(va_list args) {
|
void vargs_good(va_list args) {
|
||||||
char x[100];
|
char x[100];
|
||||||
int y;
|
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;
|
int nothundred = 100;
|
||||||
nothundred = 99;
|
nothundred = 99;
|
||||||
vsnprintf(x, nothundred, "what", args);
|
vsnprintf(x, nothundred, "foo", args);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче