Skip to content

Commit

Permalink
app/testpmd: fix build on signed comparison
Browse files Browse the repository at this point in the history
Build error:
.../app/test-pmd/config.c: In function 'icmp_echo_config_setup':
.../app/test-pmd/config.c:5159:30:
   error: comparison between signed and unsigned integer expressions
          [-Werror=sign-compare]
  if ((nb_txq * nb_fwd_ports) < nb_fwd_lcores)
                              ^
All 'nb_txq', 'nb_fwd_ports' & 'nb_fwd_lcores' are unsigned variables,
but the warning is related to the integer promotion rules of C:
'nb_txq'       -> uint16_t, promoted to 'int'
'nb_fwd_ports' -> uint16_t, promoted to 'int'
(nb_txq * nb_fwd_ports) -> result 'int'
nb_fwd_lcores  -> 'uint32_t'
Ends up comparing 'int' vs 'uint32_t'.

Fixing by adding the casting back which was initially part of the patch.

Fixes: 2bf44dd ("app/testpmd: fix lcore ID restriction")
Cc: stable@dpdk.org

Reported-by: Raslan Darawsheh <rasland@nvidia.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
ferruhy authored and ovsrobot committed Jul 22, 2024
1 parent fa8d2f7 commit ef92fcc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/test-pmd/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -5156,7 +5156,7 @@ icmp_echo_config_setup(void)
lcoreid_t lc_id;
uint16_t sm_id;

if ((nb_txq * nb_fwd_ports) < nb_fwd_lcores)
if ((lcoreid_t)(nb_txq * nb_fwd_ports) < nb_fwd_lcores)
cur_fwd_config.nb_fwd_lcores = (lcoreid_t)
(nb_txq * nb_fwd_ports);
else
Expand Down

0 comments on commit ef92fcc

Please sign in to comment.