From: Julien Cretin Date: Mon, 12 May 2014 15:35:09 +0000 (+0200) Subject: app/testpmd: fix minor signed overflow in a constant X-Git-Tag: spdx-start~10841 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=6f8d4ded4affdfe051d0b8ea66f06dd71675451a;p=dpdk.git app/testpmd: fix minor signed overflow in a constant The expression (192 << 24) has an undefined behavior since: - the integer constant 192 has type int, and - 192 x 2^24 is not representable as an int. Suffixing 192 with U defines a behavior since: - the integer constant 192U has type unsigned int, and - the value of (192U << 24) is defined as (192 x 2^24) % (UINT_MAX + 1) This minor bug was found using TrustInSoft Analyzer. Signed-off-by: Julien Cretin Acked-by: Thomas Monjalon --- diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 1cf2574232..5bbd34fa34 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -76,8 +76,8 @@ #define UDP_SRC_PORT 1024 #define UDP_DST_PORT 1024 -#define IP_SRC_ADDR ((192 << 24) | (168 << 16) | (0 << 8) | 1) -#define IP_DST_ADDR ((192 << 24) | (168 << 16) | (0 << 8) | 2) +#define IP_SRC_ADDR ((192U << 24) | (168 << 16) | (0 << 8) | 1) +#define IP_DST_ADDR ((192U << 24) | (168 << 16) | (0 << 8) | 2) #define IP_DEFTTL 64 /* from RFC 1340. */ #define IP_VERSION 0x40