linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Levin, Alexander" <alexander.levin@verizon.com>
To: "mingo@redhat.com" <mingo@redhat.com>,
	"peterz@infradead.org" <peterz@infradead.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Ben Hutchings <ben@decadent.org.uk>,
	"Levin, Alexander" <alexander.levin@verizon.com>
Subject: [PATCH 5/8] liblockdep: Fix 'unused value' warnings
Date: Fri, 29 Jul 2016 23:02:14 -0400	[thread overview]
Message-ID: <1469847222-21313-6-git-send-email-alexander.levin@verizon.com> (raw)
In-Reply-To: <1469847222-21313-1-git-send-email-alexander.levin@verizon.com>

From: Ben Hutchings <ben@decadent.org.uk>

liblockdep defines various macros that may expand to an expression
with no effect, while the in-kernel definition does have an effect.
This results in warnings from gcc when -Wunused-value is enabled, and
is is enabled by -Wall.  Fix this by introducing trivial functions,
as function return values are generally allowed to be ignored.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 tools/lib/lockdep/uinclude/linux/debug_locks.h |  2 +-
 tools/lib/lockdep/uinclude/linux/kernel.h      | 12 +++++++++---
 tools/lib/lockdep/uinclude/linux/lockdep.h     |  6 +++++-
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/tools/lib/lockdep/uinclude/linux/debug_locks.h b/tools/lib/lockdep/uinclude/linux/debug_locks.h
index f38eb64..1d4fbec 100644
--- a/tools/lib/lockdep/uinclude/linux/debug_locks.h
+++ b/tools/lib/lockdep/uinclude/linux/debug_locks.h
@@ -4,7 +4,7 @@
 #include <stddef.h>
 #include <linux/compiler.h>
 
-#define DEBUG_LOCKS_WARN_ON(x) (x)
+#define DEBUG_LOCKS_WARN_ON(x) WARN_ON(x)
 
 extern bool debug_locks;
 extern bool debug_locks_silent;
diff --git a/tools/lib/lockdep/uinclude/linux/kernel.h b/tools/lib/lockdep/uinclude/linux/kernel.h
index da87bd9..021cff4 100644
--- a/tools/lib/lockdep/uinclude/linux/kernel.h
+++ b/tools/lib/lockdep/uinclude/linux/kernel.h
@@ -22,10 +22,16 @@
 	_max1 > _max2 ? _max1 : _max2; })
 
 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
-#define WARN_ON(x) (x)
-#define WARN_ON_ONCE(x) (x)
+
+static inline int lockdep_warn(int condition)
+{
+	return condition;
+}
+#define WARN_ON(x) lockdep_warn(x)
+#define WARN_ON_ONCE(x) WARN_ON(x)
+#define WARN(x, y...) WARN_ON(x)
+
 #define likely(x) (x)
-#define WARN(x, y...) (x)
 #define uninitialized_var(x) x
 #define __init
 #define noinline
diff --git a/tools/lib/lockdep/uinclude/linux/lockdep.h b/tools/lib/lockdep/uinclude/linux/lockdep.h
index d302142..d107903 100644
--- a/tools/lib/lockdep/uinclude/linux/lockdep.h
+++ b/tools/lib/lockdep/uinclude/linux/lockdep.h
@@ -29,7 +29,11 @@ extern struct task_struct *__curr(void);
 
 #define current (__curr())
 
-#define debug_locks_off() 1
+static inline int debug_locks_off(void)
+{
+	return 1;
+}
+
 #define task_pid_nr(tsk) ((tsk)->pid)
 
 #define KSYM_NAME_LEN 128
-- 
2.7.4

  parent reply	other threads:[~2016-07-30  3:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-30  3:02 [PATCH resend 0/8] liblockdep fixes for 3.8 Levin, Alexander
2016-07-30  3:02 ` [PATCH 1/8] liblockdep: Fix undefined symbol prandom_u32 Levin, Alexander
2016-07-30  3:02 ` [PATCH 4/8] liblockdep: Enable -Wall by default Levin, Alexander
2016-07-30  3:02 ` [PATCH 2/8] liblockdep: Reduce MAX_LOCK_DEPTH to avoid overflowing lock_chain::depth Levin, Alexander
2016-07-30  3:02 ` [PATCH 3/8] liblockdep: Define the ARRAY_SIZE() macro Levin, Alexander
2016-07-30  3:02 ` [PATCH 6/8] liblockdep: Fix 'set but not used' warnings Levin, Alexander
2016-07-30  3:02 ` Levin, Alexander [this message]
2016-07-30  3:02 ` [PATCH 7/8] liblockdep: Fix 'defined but not used' warning for init_utsname() Levin, Alexander
2016-07-30  3:02 ` [PATCH 8/8] liblockdep: Remove -lpthread compiler option Levin, Alexander

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=1469847222-21313-6-git-send-email-alexander.levin@verizon.com \
    --to=alexander.levin@verizon.com \
    --cc=ben@decadent.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).