From: "Guillermo O. Freschi" <kedrot@gmail.com>
To: Aditya Shankar <aditya.shankar@microchip.com>,
Ganesh Krishna <ganesh.krishna@microchip.com>,
linux-wireless@vger.kernel.org
Cc: "Guillermo O. Freschi" <kedrot@gmail.com>
Subject: [PATCH] drivers: staging: wilc1000/host_interface.c Fix sparse warning: right shift by bigger than source value
Date: Sun, 25 Jun 2017 11:40:51 -0300 [thread overview]
Message-ID: <20170625144051.28873-1-kedrot@gmail.com> (raw)
Shifting by equal to or bigger than the width of a type results in
undefined behavior. By using a wide enough temporary variable the issue
can be avoided.
Signed-off-by: Guillermo O. Freschi <kedrot@gmail.com>
---
drivers/staging/wilc1000/host_interface.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index f7c22d7b28d1..ed614698c22c 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -2416,10 +2416,12 @@ static void Handle_SetMulticastFilter(struct wilc_vif *vif,
goto ERRORHANDLER;
pu8CurrByte = wid.val;
- *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
- *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF);
- *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF);
- *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF);
+
+ u32 enabled = strHostIfSetMulti->enabled;
+ *pu8CurrByte++ = (enabled & 0xFF);
+ *pu8CurrByte++ = ((enabled >> 8) & 0xFF);
+ *pu8CurrByte++ = ((enabled >> 16) & 0xFF);
+ *pu8CurrByte++ = ((enabled >> 24) & 0xFF);
*pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
*pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
--
2.11.0
next reply other threads:[~2017-06-25 14:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-25 14:40 Guillermo O. Freschi [this message]
2017-06-26 10:27 ` [PATCH] drivers: staging: wilc1000/host_interface.c Fix sparse warning: right shift by bigger than source value kbuild test robot
2017-06-26 11:29 ` [PATCH v2] " Guillermo O. Freschi
2017-06-26 11:47 ` Guillermo O. Freschi
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=20170625144051.28873-1-kedrot@gmail.com \
--to=kedrot@gmail.com \
--cc=aditya.shankar@microchip.com \
--cc=ganesh.krishna@microchip.com \
--cc=linux-wireless@vger.kernel.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).