From: Chuck Ebbert <cebbert.lkml@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH -next] static-keys: Better error checking for static_key_enable/disable
Date: Thu, 27 Aug 2015 16:57:13 -0400 [thread overview]
Message-ID: <20150827165713.7fc9ff4c@as> (raw)
The warnings for static_key_enable/disable don't catch common
errors. For example, starting with a default enabled key and
calling enable doesn't cause a warning until the next enable
or disable. Check explicitly for zero or one instead of allowing
both values in every case. Generated code should be smaller too.
Signed-off-by: Chuck Ebbert <cebbert.lkml@gmail.com>
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 7f653e8..ba9ca0c 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -225,7 +225,7 @@ static inline void static_key_enable(struct static_key *key)
{
int count = static_key_count(key);
- WARN_ON_ONCE(count < 0 || count > 1);
+ WARN_ON_ONCE(count);
if (!count)
static_key_slow_inc(key);
@@ -235,7 +235,7 @@ static inline void static_key_disable(struct static_key *key)
{
int count = static_key_count(key);
- WARN_ON_ONCE(count < 0 || count > 1);
+ WARN_ON_ONCE(count != 1);
if (count)
static_key_slow_dec(key);
next reply other threads:[~2015-08-27 20:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 20:57 Chuck Ebbert [this message]
2015-08-27 22:23 ` [PATCH -next] static-keys: Better error checking for static_key_enable/disable Peter Zijlstra
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=20150827165713.7fc9ff4c@as \
--to=cebbert.lkml@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.