From 71ac4d413df64346b31621806582378d6cb4480b Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Mon, 28 Aug 2023 20:53:30 +0000 Subject: [PATCH] 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 --- build/clang-plugin/tests/TestSprintfLiteral.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build/clang-plugin/tests/TestSprintfLiteral.cpp b/build/clang-plugin/tests/TestSprintfLiteral.cpp index a8dac4009cdf..3c54ce004f27 100644 --- a/build/clang-plugin/tests/TestSprintfLiteral.cpp +++ b/build/clang-plugin/tests/TestSprintfLiteral.cpp @@ -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); }