about summary refs log tree commit diff
path: root/malloc
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2017-11-14 17:52:26 +0000
committerJoseph Myers <joseph@codesourcery.com>2017-11-14 17:52:26 +0000
commit2e64ec9c9eac3aeb70f7cfa2392846c87c28068e (patch)
treeac6498ad9e92047fdcb0c4c375e68e7ef6e13f50 /malloc
parentec72135e5f1d061cb5cf7cd1b855fd6290be10d9 (diff)
downloadglibc-2e64ec9c9eac3aeb70f7cfa2392846c87c28068e.tar.gz
glibc-2e64ec9c9eac3aeb70f7cfa2392846c87c28068e.tar.xz
glibc-2e64ec9c9eac3aeb70f7cfa2392846c87c28068e.zip
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.
Diffstat (limited to 'malloc')
0 files changed, 0 insertions, 0 deletions