Hide memset/bzero from compiler

Hide memset/bzero from compiler to silence Clang error:

./tester.c:1345:29: error: 'size' argument to memset is '0'; did you mean to transpose the last two arguments? [-Werror,-Wmemset-transposed-args]
 1345 |   (void) memset(one+2, 'y', 0);
      |                             ^
./tester.c:1345:29: note: parenthesize the third argument to silence
./tester.c:1432:16: error: 'size' argument to bzero is '0' [-Werror,-Wsuspicious-bzero]
 1432 |   bzero(one+2, 0);
      |                ^
./tester.c:1432:16: note: parenthesize the second argument to silence

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
This commit is contained in:
H.J. Lu 2024-12-18 02:38:26 +08:00
parent eb02fb7739
commit 3d54e957c9
1 changed files with 9 additions and 0 deletions

View File

@ -50,6 +50,15 @@ DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overread");
#include <strings.h>
#include <fcntl.h>
static __typeof (bzero) * volatile bzero_indirect = bzero;
static __typeof (memset) * volatile memset_indirect = memset;
#undef bzero
#undef memset
#define bzero bzero_indirect
#define memset memset_indirect
/* This file tests a range of corner cases of string functions,
including cases where truncation occurs or where sizes specified
are larger than the actual buffers, which result in various