From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 6CB393857705; Mon, 24 Jul 2023 18:54:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6CB393857705 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1690224894; bh=k5CkRgcD3j1AxW38YTZXlxaWqoH5IJwBZp3VJn/F0HA=; h=From:To:Subject:Date:From; b=E8s/WqGeN12lDLMbuV65M2/CHhSAebqjV12MMHvz6KDwOLJk3cdrK6otV+rTZ2qiG ffIvEeXAyDkOkT064FEoXdcUs6gEKEVK/b+sOEvJO1mCYgWjuqt81xAuFraI7nioQX 8M4h7BXZRlDVVO/97d6lhsElv9O5CTnO77yCCsYA= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc] string: Fix tester with fortify enabled X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella Netto X-Git-Refname: refs/heads/master X-Git-Oldrev: 85ac7edcdf67010c223541936243427213ac87a6 X-Git-Newrev: c2dc8ab6a5a4e67f96ddd3f6bfdf2c991385ec38 Message-Id: <20230724185454.6CB393857705@sourceware.org> Date: Mon, 24 Jul 2023 18:54:54 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c2dc8ab6a5a4e67f96ddd3f6bfdf2c991385ec38 commit c2dc8ab6a5a4e67f96ddd3f6bfdf2c991385ec38 Author: Adhemerval Zanella Netto Date: Fri Jul 21 09:18:17 2023 -0300 string: Fix tester with fortify enabled If fortify is enabled, the truncated output warning is issued by the wrapper itself: In function ‘strncpy’, inlined from ‘test_strncpy’ at tester.c:505:10: ../string/bits/string_fortified.h:95:10: error: ‘__builtin_strncpy’ destination unchanged after copying no bytes from a string of length 3 [-Werror=stringop-truncation] 95 | return __builtin___strncpy_chk (__dest, __src, __len, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 96 | __glibc_objsize (__dest)); | ~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ../include/bits/string_fortified.h:1, from ../string/string.h:548, from ../include/string.h:60, from tester.c:33, from inl-tester.c:6: In function ‘strncpy’, inlined from ‘test_strncpy’ at tester.c:505:10: Checked on x86_64-linux-gnu. Reviewed-by: Carlos O'Donell Diff: --- string/tester.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/string/tester.c b/string/tester.c index 8de70ad3ce..da42c72141 100644 --- a/string/tester.c +++ b/string/tester.c @@ -26,6 +26,14 @@ #undef __USE_STRING_INLINES #endif +#include +#include + +/* Triggered by strncpy fortify wrapper when it is enabled. */ +#if __GNUC_PREREQ (8, 0) +DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-truncation"); +#endif + #include #include #include @@ -33,7 +41,6 @@ #include #include #include -#include /* This file tests a range of corner cases of string functions, including cases where truncation occurs or where sizes specified @@ -45,9 +52,6 @@ DIAG_IGNORE_NEEDS_COMMENT (5.0, "-Wmemset-transposed-args"); DIAG_IGNORE_NEEDS_COMMENT (9, "-Wrestrict"); DIAG_IGNORE_NEEDS_COMMENT (7, "-Wstringop-overflow="); #endif -#if __GNUC_PREREQ (8, 0) -DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-truncation"); -#endif #if __GNUC_PREREQ (11, 0) DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overread"); #endif