]> git.ipfire.org Git - thirdparty/glibc.git/commit
Fix string/tester.c build with GCC 8.
authorJoseph Myers <joseph@codesourcery.com>
Tue, 14 Nov 2017 17:52:26 +0000 (17:52 +0000)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 22 Oct 2018 12:15:28 +0000 (14:15 +0200)
commitdd03d15e283de6c2fff8f5204b092e9d9d127cc6
tree4c4da041b22dc757daf255b0ad60bb3e626972c9
parent935cecfe9a4c9bf0396766f5e2b24570f92317ae
Fix string/tester.c build with GCC 8.

GCC 8 warns about more cases of string functions truncating their
output or not copying a trailing NUL byte.

This patch fixes testsuite build failures caused by such warnings in
string/tester.c.  In general, the warnings are disabled around the
relevant calls using DIAG_* macros, since the relevant cases are being
deliberately tested.  In one case, the warning is with
-Wstringop-overflow= instead of -Wstringop-truncation; in that case,
the conditional is __GNUC_PREREQ (7, 0) (being the version where
-Wstringop-overflow= was introduced), to allow the conditional to be
removed sooner, since it's harmless to disable the warning for a
GCC version where it doesn't actually occur.  In the case of warnings
for strncpy calls in test_memcmp, the calls in question are changed to
use memcpy, as they don't copy a trailing NUL and the point of that
code is to test memcmp rather than strncpy.

Tested (compilation) with GCC 8 for x86_64-linux-gnu with
build-many-glibcs.py (in conjunction with Martin's patch to allow
glibc to build).

* string/tester.c (test_stpncpy): Disable -Wstringop-truncation
for stpncpy calls for GCC 8.
(test_strncat): Disable -Wstringop-truncation warning for strncat
calls for GCC 8.  Disable -Wstringop-overflow= warning for one
strncat call for GCC 7.
(test_strncpy): Disable -Wstringop-truncation warning for strncpy
calls for GCC 8.
(test_memcmp): Use memcpy instead of strncpy for calls not copying
trailing NUL.

(cherry picked from commit 2e64ec9c9eac3aeb70f7cfa2392846c87c28068e)
ChangeLog
string/tester.c