Skip to contentSkip to conversation

app/testpmd: fix unintentional integer overflow

PATCH Applied Tiwei Bie 3 participants 3 messages Apr 24, 2019

lore
Share & tools
lore

Tiwei Bie

author
#0 lore raw

PATCH 1/1 app/testpmd: fix unintentional integer overflow

Fix the potential overflow in expression 1 << begin by using 1ULL.

Coverity issue: 279437, 279445

Fixes c73a9071877a ("app/testpmd: add commands to test new offload API")
---
 app/test-pmd/cmdline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/cmdline.c +2 -2
index 5a10c5f38..03926f913 100644
@@ -17739,7 +17739,7 @@ print_rx_offloads(uint64_t offloads)
 	begin = __builtin_ctzll(offloads);
 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
 
-	single_offload = 1 << begin;
+	single_offload = 1ULL << begin;
 	for (bit = begin; bit < end; bit++) {
 		if (offloads & single_offload)
 			printf(" %s",
@@ -18133,7 +18133,7 @@ print_tx_offloads(uint64_t offloads)
 	begin = __builtin_ctzll(offloads);
 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
 
-	single_offload = 1 << begin;
+	single_offload = 1ULL << begin;
 	for (bit = begin; bit < end; bit++) {
 		if (offloads & single_offload)
 			printf(" %s",
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines

-----Original Message-----
From: Bie, Tiwei
Sent: Wednesday, April 24, 2019 3:30 AM
To: Lu, Wenzhuo <[email protected]>; Wu, Jingjing <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]
Cc: [email protected]
Subject: [PATCH] app/testpmd: fix unintentional integer overflow

Quoted 7 lines

Fix the potential overflow in expression 1 << begin by using 1ULL.

Coverity issue: 279437, 279445

Fixes c73a9071877a ("app/testpmd: add commands to test new offload API")
Applied
#2 lore raw
Quoted 11 lines · Bernard
Quoted 11 lines

-----Original Message-----
From: Bie, Tiwei
Sent: Wednesday, April 24, 2019 3:30 AM
To: Lu, Wenzhuo <[email protected]>; Wu, Jingjing <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]
Cc: [email protected]
Subject: [PATCH] app/testpmd: fix unintentional integer overflow

Fix the potential overflow in expression 1 << begin by using 1ULL.

Quoted 8 lines
Quoted 5 lines

Coverity issue: 279437, 279445

Fixes c73a9071877a ("app/testpmd: add commands to test new offload API")

Applied to dpdk-next-net/master, thanks.