* [PATCH] atm: he: use 64-bit arithmetic instead of 32-bit
@ 2018-02-07 16:17 Gustavo A. R. Silva
2018-02-08 20:05 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2018-02-07 16:17 UTC (permalink / raw)
To: Chas Williams
Cc: linux-atm-general, netdev, linux-kernel, Gustavo A. R. Silva
Add suffix ULL to constants 272, 204, 136 and 68 in order to give the
compiler complete information about the proper arithmetic to use.
Notice that these constants are used in contexts that expect
expressions of type unsigned long long (64 bits, unsigned).
The following expressions are currently being evaluated using 32-bit
arithmetic:
272 * mult
204 * mult
136 * mult
68 * mult
Addresses-Coverity-ID: 201058
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/atm/he.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index e58538c..29f102d 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -738,13 +738,13 @@ static int he_init_cs_block_rcm(struct he_dev *he_dev)
#else
/* this is pretty, but avoids _divdu3 and is mostly correct */
mult = he_dev->atm_dev->link_rate / ATM_OC3_PCR;
- if (rate_cps > (272 * mult))
+ if (rate_cps > (272ULL * mult))
buf = 4;
- else if (rate_cps > (204 * mult))
+ else if (rate_cps > (204ULL * mult))
buf = 3;
- else if (rate_cps > (136 * mult))
+ else if (rate_cps > (136ULL * mult))
buf = 2;
- else if (rate_cps > (68 * mult))
+ else if (rate_cps > (68ULL * mult))
buf = 1;
else
buf = 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] atm: he: use 64-bit arithmetic instead of 32-bit
2018-02-07 16:17 [PATCH] atm: he: use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
@ 2018-02-08 20:05 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-02-08 20:05 UTC (permalink / raw)
To: gustavo; +Cc: 3chas3, linux-atm-general, netdev, linux-kernel, garsilva
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Wed, 7 Feb 2018 10:17:29 -0600
> Add suffix ULL to constants 272, 204, 136 and 68 in order to give the
> compiler complete information about the proper arithmetic to use.
> Notice that these constants are used in contexts that expect
> expressions of type unsigned long long (64 bits, unsigned).
>
> The following expressions are currently being evaluated using 32-bit
> arithmetic:
>
> 272 * mult
> 204 * mult
> 136 * mult
> 68 * mult
>
> Addresses-Coverity-ID: 201058
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-08 20:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-07 16:17 [PATCH] atm: he: use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
2018-02-08 20:05 ` David Miller
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).