The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: George Spelvin <linux@sciencehorizons.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] hash: fix gcc-4 build warnings in test_hash.c
Date: Tue, 31 May 2016 10:30:25 +0200	[thread overview]
Message-ID: <1464683443-2900765-1-git-send-email-arnd@arndb.de> (raw)

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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 lib/test_hash.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/test_hash.c b/lib/test_hash.c
index c9549c8b4909..ad136bbf1465 100644
--- a/lib/test_hash.c
+++ b/lib/test_hash.c
@@ -143,7 +143,7 @@ static int __init
 test_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
 
-- 
2.7.0

             reply	other threads:[~2016-05-31  8:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-31  8:30 Arnd Bergmann [this message]
2016-05-31  9:46 ` [PATCH] hash: fix gcc-4 build warnings in test_hash.c George Spelvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464683443-2900765-1-git-send-email-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@sciencehorizons.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox