Bug 979 - hash: invalid shift expression in rte_thash
Summary: hash: invalid shift expression in rte_thash
Status: UNCONFIRMED
Alias: None
Product: DPDK
Classification: Unclassified
Component: other (show other bugs)
Version: 21.11
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Vladimir
URL:
Depends on:
Blocks:
 
Reported: 2022-03-24 16:08 CET by David Marchand
Modified: 2022-03-24 19:02 CET (History)
1 user (show)



Attachments

Description David Marchand 2022-03-24 16:08:29 CET
This has been reported by covscan in our internal CI for v21.11:

2. dpdk-21.11/lib/hash/rte_thash.c:116: assignment: Assigning: "j" = "0".
4. dpdk-21.11/lib/hash/rte_thash.c:118: large_shift: In expression "(uint16_t)rss_key[(i + 1) % size] >> 8 - j", right shifting "rss_key[(i + 1) % size]" by more than 7 bits always yields zero. The shift amount, "8 - j", is 8.
#   116|   		for (j = 0; j < 8; j++) {
#   117|   			left_part = rss_key[i] << j;
#   118|-> 			right_part = (uint16_t)(rss_key[(i + 1) % size]) >>
#   119|   				(8 - j);
#   120|   			m[i * 8 + j] = left_part|right_part;
Comment 1 Vladimir 2022-03-24 19:02:45 CET
Hi David,

This is exactly what I wanted. Here I just read an unaligned byte, and when j == 0, I need to read only "left_part". So I would suggest marking this as intentional in coverity.

Note You need to log in before you can comment on or make changes to this bug.