hash: fix gcc-4 build warnings in test_hash.c
PATCH 1/1 hash: fix gcc-4 build warnings in test_hash.c
The newly added lib/test_hash.c file builds fine with gcc-5 or newer, but causes some annoying warnings witih gcc-4.9 and older:
lib/test_hash.c: In function ‘test_hash_init’:lib/test_hash.c:146:2: error: missing braces around initializer [-Werror=missing-braces] lib/test_hash.c:146:2: error: (near initialization for ‘hash_or[0]’) [-Werror=missing-braces] lib/test_hash.c:224:7: error: "HAVE_ARCH__HASH_32" is not defined [-Werror=undef] lib/test_hash.c:229:7: error: "HAVE_ARCH_HASH_32" is not defined [-Werror=undef] lib/test_hash.c:234:7: error: "HAVE_ARCH_HASH_64" is not defined [-Werror=undef]
This adds the braces and extra #ifdef checks for the macros to shut up those warnings.
--- lib/test_hash.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/test_hash.c +4 -4
@@ -143,7 +143,7 @@ static int __inittest_hash_init (void) {char buf[SIZE +1 ]; -u32 string_or =0 , hash_or[2 ][33 ] = {0 }; +u32 string_or =0 , hash_or[2 ][33 ] = { {0 } };unsigned tests =0 ;unsigned long long h64 =0 ;int i, j;
@@ -221,17 +221,17 @@ test_hash_init(void)/* Issue notices about skipped tests. */ #ifndef HAVE_ARCH__HASH_32 pr_info ("__hash_32() has no arch implementation to test." ); -#elif HAVE_ARCH__HASH_32 !=1 +#elif defined(HAVE_ARCH__HASH_32 ) &&HAVE_ARCH__HASH_32 !=1 pr_info ("__hash_32() is arch-specific; not compared to generic." );#endif #ifndef HAVE_ARCH_HASH_32 pr_info ("hash_32() has no arch implementation to test." ); -#elif HAVE_ARCH_HASH_32 !=1 +#elif defined(HAVE_ARCH_HASH_32 ) &&HAVE_ARCH_HASH_32 !=1 pr_info ("hash_32() is arch-specific; not compared to generic." );#endif #ifndef HAVE_ARCH_HASH_64 pr_info ("hash_64() has no arch implementation to test." ); -#elif HAVE_ARCH_HASH_64 !=1 +#elif defined(HAVE_ARCH_HASH_64 ) &&HAVE_ARCH_HASH_64 !=1 pr_info ("hash_64() is arch-specific; not compared to generic." );#endif
Signature · 1 line
2.7.0
Quoted 2 lines · Arnd Bergmann
The newly added
lib/test_hash.cfile builds fine with gcc-5 or newer, but causes some annoying warnings witih gcc-4.9 and older:
The fix is already in the queue, thanks to Geert Uytterhoeven <[email protected]>.