Skip to contentSkip to conversation

atm: he: use 64-bit arithmetic instead of 32-bit

PATCH Applied Gustavo A. R. Silva 2 participants 2 messages Feb 7, 2018 – Feb 8, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 atm: he: use 64-bit arithmetic instead of 32-bit

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

---
 drivers/atm/he.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/atm/he.c +4 -4
index e58538c..29f102d 100644
@@ -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;
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw

From: "Gustavo A. R. Silva" <[email protected]>
Date: Wed, 7 Feb 2018 10:17:29 -0600

Quoted 8 lines

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:

Quoted 7 lines

272 * mult
204 * mult
136 * mult
68 * mult

Addresses-Coverity-ID: 201058

Applied, thanks.