All of lore.kernel.org
 help / color / mirror / Atom feed
From: Colin King <colin.king@canonical.com>
To: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>,
	linux-wimax@intel.com, "David S . Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] wimax/i2400m: fix calculation of index, remove sizeof
Date: Fri, 23 Aug 2019 09:52:30 +0100	[thread overview]
Message-ID: <20190823085230.6225-1-colin.king@canonical.com> (raw)

From: Colin Ian King <colin.king@canonical.com>

The subtraction of the two pointers is automatically scaled by the
size of the size of the object the pointers point to, so the division
by sizeof(*i2400m->barker) is incorrect.  Fix this by removing the
division.  Also make index an unsigned int to clean up a checkpatch
warning.

Addresses-Coverity: ("Extra sizeof expression")
Fixes: aba3792ac2d7 ("wimax/i2400m: rework bootrom initialization to be more flexible")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/wimax/i2400m/fw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wimax/i2400m/fw.c b/drivers/net/wimax/i2400m/fw.c
index 489cba9b284d..599a703af6eb 100644
--- a/drivers/net/wimax/i2400m/fw.c
+++ b/drivers/net/wimax/i2400m/fw.c
@@ -399,8 +399,7 @@ int i2400m_is_boot_barker(struct i2400m *i2400m,
 	 * associated with the device. */
 	if (i2400m->barker
 	    && !memcmp(buf, i2400m->barker, sizeof(i2400m->barker->data))) {
-		unsigned index = (i2400m->barker - i2400m_barker_db)
-			/ sizeof(*i2400m->barker);
+		unsigned int index = i2400m->barker - i2400m_barker_db;
 		d_printf(2, dev, "boot barker cache-confirmed #%u/%08x\n",
 			 index, le32_to_cpu(i2400m->barker->data[0]));
 		return 0;
-- 
2.20.1


WARNING: multiple messages have this Message-ID (diff)
From: Colin King <colin.king@canonical.com>
To: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>,
	linux-wimax@intel.com, "David S . Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] wimax/i2400m: fix calculation of index, remove sizeof
Date: Fri, 23 Aug 2019 08:52:30 +0000	[thread overview]
Message-ID: <20190823085230.6225-1-colin.king@canonical.com> (raw)

From: Colin Ian King <colin.king@canonical.com>

The subtraction of the two pointers is automatically scaled by the
size of the size of the object the pointers point to, so the division
by sizeof(*i2400m->barker) is incorrect.  Fix this by removing the
division.  Also make index an unsigned int to clean up a checkpatch
warning.

Addresses-Coverity: ("Extra sizeof expression")
Fixes: aba3792ac2d7 ("wimax/i2400m: rework bootrom initialization to be more flexible")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/wimax/i2400m/fw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wimax/i2400m/fw.c b/drivers/net/wimax/i2400m/fw.c
index 489cba9b284d..599a703af6eb 100644
--- a/drivers/net/wimax/i2400m/fw.c
+++ b/drivers/net/wimax/i2400m/fw.c
@@ -399,8 +399,7 @@ int i2400m_is_boot_barker(struct i2400m *i2400m,
 	 * associated with the device. */
 	if (i2400m->barker
 	    && !memcmp(buf, i2400m->barker, sizeof(i2400m->barker->data))) {
-		unsigned index = (i2400m->barker - i2400m_barker_db)
-			/ sizeof(*i2400m->barker);
+		unsigned int index = i2400m->barker - i2400m_barker_db;
 		d_printf(2, dev, "boot barker cache-confirmed #%u/%08x\n",
 			 index, le32_to_cpu(i2400m->barker->data[0]));
 		return 0;
-- 
2.20.1

             reply	other threads:[~2019-08-23  8:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23  8:52 Colin King [this message]
2019-08-23  8:52 ` [PATCH] wimax/i2400m: fix calculation of index, remove sizeof Colin King
2019-08-23 11:23 ` Dan Carpenter
2019-08-23 11:23   ` Dan Carpenter
2019-08-23 11:27   ` Colin Ian King
2019-08-23 11:27     ` Colin Ian King
2019-08-23 21:30     ` David Miller
2019-08-23 21:30       ` David Miller

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=20190823085230.6225-1-colin.king@canonical.com \
    --to=colin.king@canonical.com \
    --cc=davem@davemloft.net \
    --cc=inaky.perez-gonzalez@intel.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wimax@intel.com \
    --cc=netdev@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.