LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Paul Bolle <pebolle@tiscali.nl>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Stanislav Kinsbursky <skinsbursky@parallels.com>,
	"J. Bruce Fields" <bfields@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Silence warning if CONFIG_LOCKDEP isn't set
Date: Thu, 24 Jan 2013 21:53:17 +0100
Message-ID: <1359060797.1325.33.camel@x61.thuisdomein> (raw)

Since commit c9a4962881929df7f1ef6e63e1b9da304faca4dd ("nfsd: make
client_lock per net") compiling nfs4state.o without CONFIG_LOCKDEP set,
triggers this GCC warning:
    fs/nfsd/nfs4state.c: In function ‘free_client’:
    fs/nfsd/nfs4state.c:1051:19: warning: unused variable ‘nn’ [-Wunused-variable]

The cause of that warning is that lockdep_assert_held() compiles away if
CONFIG_LOCKDEP is not set. Silence this warning by using the argument to
lockdep_assert_held() as a nop if CONFIG_LOCKDEP is not set.

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
---
0) Compile tested only.

1) This patch triggers a checkpatch false positive:
    WARNING: Single statement macros should not use a do {} while (0) loop

2) Review is rather needed here, since I'm not sure what, if any, the
downsides are of this patch for all other "calls" of
lockdep_assert_held(). Besides, a cleaner solution might be to simply
drop lockdep_assert_held() in free_client(). There are only three
callers of that function and it seems obvious that all three do hold
'client_lock'.

 include/linux/lockdep.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 2bca44b..f05631e 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -410,7 +410,7 @@ struct lock_class_key { };
 
 #define lockdep_depth(tsk)	(0)
 
-#define lockdep_assert_held(l)			do { } while (0)
+#define lockdep_assert_held(l)			do { (void)(l); } while (0)
 
 #define lockdep_recursing(tsk)			(0)
 
-- 
1.7.11.7


             reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-24 20:53 Paul Bolle [this message]
2013-01-25 10:40 ` [tip:core/locking] lockdep: Silence warning if CONFIG_LOCKDEP isn 't set tip-bot for Paul Bolle
2013-02-22 12:24 ` tip-bot for Paul Bolle

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=1359060797.1325.33.camel@x61.thuisdomein \
    --to=pebolle@tiscali.nl \
    --cc=bfields@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=skinsbursky@parallels.com \
    /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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git