All of lore.kernel.org
 help / color / mirror / Atom feed
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 v2] drivers: staging: wilc1000/host_interface.c Fix sparse warning: right shift by bigger than source value
Date: Mon, 26 Jun 2017 08:47:01 -0300	[thread overview]
Message-ID: <20170626114701.9769-1-kedrot@gmail.com> (raw)
In-Reply-To: <20170625144051.28873-1-kedrot@gmail.com>

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 | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index f7c22d7b28d1..4591b1452df4 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -2407,6 +2407,7 @@ static void Handle_SetMulticastFilter(struct wilc_vif *vif,
 	s32 result = 0;
 	struct wid wid;
 	u8 *pu8CurrByte;
+	u32 enabled;
 
 	wid.id = (u16)WID_SETUP_MULTICAST_FILTER;
 	wid.type = WID_BIN;
@@ -2416,10 +2417,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);
+
+	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

      parent reply	other threads:[~2017-06-26 11:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-25 14:40 [PATCH] drivers: staging: wilc1000/host_interface.c Fix sparse warning: right shift by bigger than source value Guillermo O. Freschi
2017-06-26 10:27 ` kbuild test robot
2017-06-26 11:29 ` [PATCH v2] " Guillermo O. Freschi
2017-06-26 11:47 ` Guillermo O. Freschi [this message]

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=20170626114701.9769-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 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.