Skip to content

Commit

Permalink
util/pingpong: Fix coverity issue about integer overflow
Browse files Browse the repository at this point in the history
The calculation of `power_of_two` would overflow when `i` reaches 32.
Based on the size of allocated array `sizes`, `i` should be less than
32. Add explicit loop limit to suppress the warning.

Signed-off-by: Jianxin Xiong <jianxin.xiong@intel.com>
  • Loading branch information
j-xiong committed Nov 14, 2024
1 parent fc24cad commit f0c858a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion util/pingpong.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ static int generate_test_sizes(struct pp_opts *opts, size_t tx_size, int **sizes
n++;
}
} else {
for (i = 0;; i++) {
for (i = 0; i < 32; i++) {
power_of_two = (i == 0) ? 0 : (1 << i);
half_up =
(i == 0) ? 1 : power_of_two + (power_of_two / 2);
Expand Down

0 comments on commit f0c858a

Please sign in to comment.