From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
To: John Linville <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org, Ivo van Doorn <ivdoorn@gmail.com>,
Henrique de Moraes Holschuh <hmh@hmh.eng.br>,
Ivo van Doorn <IvDoorn@gmail.com>
Subject: [PATCH 3/4] rfkill: defensive use of test_bit
Date: Fri, 27 Mar 2009 12:44:10 -0300 [thread overview]
Message-ID: <1238168651-28891-4-git-send-email-hmh@hmh.eng.br> (raw)
In-Reply-To: <1238168651-28891-1-git-send-email-hmh@hmh.eng.br>
test_bit can return negative values for true, not just 0 or 1. This
has already caused a bug in rfkill once, so it is best to take a more
defensive position in its use.
While at it, also make some booleans more explicit.
This change is for future-proofing, the code works as-is.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Ivo van Doorn <IvDoorn@gmail.com>
---
net/rfkill/rfkill-input.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/rfkill/rfkill-input.c b/net/rfkill/rfkill-input.c
index 84efde9..d8a9b70 100644
--- a/net/rfkill/rfkill-input.c
+++ b/net/rfkill/rfkill-input.c
@@ -173,11 +173,11 @@ static void rfkill_task_handler(struct work_struct *work)
bool c;
#ifdef RFKILL_NEED_SWSET
bool sp, s;
- sp = test_and_clear_bit(i,
+ sp = !!test_and_clear_bit(i,
task->sw_setpending);
- s = test_bit(i, task->sw_newstate);
+ s = !!test_bit(i, task->sw_newstate);
#endif
- c = test_and_clear_bit(i,
+ c = !!test_and_clear_bit(i,
task->sw_togglestate);
spin_unlock_irq(&task->lock);
@@ -280,7 +280,7 @@ static void rfkill_schedule_toggle(enum rfkill_type type)
spin_unlock_irqrestore(&rfkill_task.lock, flags);
}
-static void rfkill_schedule_evsw_rfkillall(int state)
+static void rfkill_schedule_evsw_rfkillall(bool state)
{
if (state) {
switch (rfkill_master_switch_mode) {
@@ -332,7 +332,7 @@ static void rfkill_event(struct input_handle *handle, unsigned int type,
} else if (type == EV_SW) {
switch (code) {
case SW_RFKILL_ALL:
- rfkill_schedule_evsw_rfkillall(data);
+ rfkill_schedule_evsw_rfkillall(!!data);
return;
default:
return;
@@ -381,7 +381,7 @@ static void rfkill_start(struct input_handle *handle)
if (test_bit(EV_SW, handle->dev->evbit)) {
if (test_bit(SW_RFKILL_ALL, handle->dev->swbit))
- rfkill_schedule_evsw_rfkillall(test_bit(SW_RFKILL_ALL,
+ rfkill_schedule_evsw_rfkillall(!!test_bit(SW_RFKILL_ALL,
handle->dev->sw));
/* add resync for further EV_SW events here */
}
--
1.6.2.1
next prev parent reply other threads:[~2009-03-27 15:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-27 15:44 [GIT PATCH] rfkill updates Henrique de Moraes Holschuh
2009-03-27 15:44 ` [PATCH 1/4] rfkill: minor locking fix Henrique de Moraes Holschuh
2009-03-27 15:44 ` [PATCH 2/4] rfkill: status initialization paranoia Henrique de Moraes Holschuh
2009-03-27 15:44 ` Henrique de Moraes Holschuh [this message]
2009-03-27 15:44 ` [PATCH 4/4] rfkill: allow embedded config without an userspace API Henrique de Moraes Holschuh
2009-03-27 21:33 ` [GIT PATCH] rfkill updates Johannes Berg
2009-03-28 12:36 ` Henrique de Moraes Holschuh
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=1238168651-28891-4-git-send-email-hmh@hmh.eng.br \
--to=hmh@hmh.eng.br \
--cc=ivdoorn@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.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
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