From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ex.trust-in-soft.com (ex.trust-in-soft.com [188.165.147.96]) by dpdk.org (Postfix) with ESMTP id B06FE58C4 for ; Mon, 12 May 2014 17:35:15 +0200 (CEST) Received: from localhost.localdomain (84.14.219.4) by S1688.EX1688.lan (2001:41d0:6b:b00::bca5:9360) with Microsoft SMTP Server (TLS) id 15.0.712.22; Mon, 12 May 2014 17:36:24 +0200 From: Julien Cretin To: Date: Mon, 12 May 2014 17:35:09 +0200 Message-ID: <1399908911-18829-2-git-send-email-julien.cretin@trust-in-soft.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1399908911-18829-1-git-send-email-julien.cretin@trust-in-soft.com> References: <1399908911-18829-1-git-send-email-julien.cretin@trust-in-soft.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [84.14.219.4] X-ClientProxiedBy: S1688.EX1688.lan (2001:41d0:6b:b00::bca5:9360) To S1688.EX1688.lan (2001:41d0:6b:b00::bca5:9360) Subject: [dpdk-dev] [PATCH 1/3] app/testpmd: fix minor signed overflow in a constant X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 May 2014 15:35:16 -0000 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 --- app/test-pmd/txonly.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 1cf2574..5bbd34f 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 -- 1.9.1