From patchwork Wed May 22 22:40:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 32824 Received: (qmail 80492 invoked by alias); 22 May 2019 22:40:58 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 80413 invoked by uid 89); 22 May 2019 22:40:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_SOFTFAIL autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1918, HContent-Transfer-Encoding:8bit X-HELO: mga02.intel.com From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH] Don't pass NULL pointer to error [BZ #24556] Date: Wed, 22 May 2019 15:40:53 -0700 Message-Id: <20190522224053.15351-1-hjl.tools@gmail.com> MIME-Version: 1.0 GCC 9 with -O3 will issue a warning for passing NULL pointer to ‘%s': In file included from ../include/bits/error.h:1, from ../misc/error.h:57, from ../include/error.h:2, from bench-string.h:60, from bench-strstr.c:22: In function ‘error’, inlined from ‘do_one_test’ at bench-strstr.c:149:7, inlined from ‘do_test’ at bench-strstr.c:201:5, inlined from ‘test_main’ at bench-strstr.c:220:2: ../include/bits/../../misc/bits/error.h:42:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 42 | __error_alias (__status, __errnum, __format, __va_arg_pack ()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function ‘error’, inlined from ‘do_one_test’ at bench-strstr.c:149:7, inlined from ‘do_test’ at bench-strstr.c:201:5, inlined from ‘test_main’ at bench-strstr.c:227:2: ../include/bits/../../misc/bits/error.h:42:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 42 | __error_alias (__status, __errnum, __format, __va_arg_pack ()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors We can either disable -Werror=format-overflow= or don't pass NULL pointer to error. This patch does the latter. [BZ #24556] * benchtests/bench-strstr.c (do_one_test): Don't pass NULL pointer to error. --- benchtests/bench-strstr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchtests/bench-strstr.c b/benchtests/bench-strstr.c index b4cd141083..104dd979f0 100644 --- a/benchtests/bench-strstr.c +++ b/benchtests/bench-strstr.c @@ -147,7 +147,7 @@ do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result) if (res != exp_result) { error (0, 0, "Wrong result in function %s %s %s", impl->name, - res, exp_result); + res, exp_result ? exp_result : "(null)"); ret = 1; } }