From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB374C433FE for ; Tue, 22 Feb 2022 14:13:56 +0000 (UTC) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9DC7A40DF6; Tue, 22 Feb 2022 15:13:55 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id EBBD140DF4 for ; Tue, 22 Feb 2022 15:13:54 +0100 (CET) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH] sched: fix integer handling issue Date: Tue, 22 Feb 2022 15:13:53 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D86EDB@smartserver.smartshare.dk> In-Reply-To: <20220222131851.2944637-1-megha.ajmera@intel.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] sched: fix integer handling issue Thread-Index: Adgn7sL05jqDoiO/SES6JDtxB7zGnAABwhWA References: <20220222131851.2944637-1-megha.ajmera@intel.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Megha Ajmera" , , , , X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > From: Megha Ajmera [mailto:megha.ajmera@intel.com] > Sent: Tuesday, 22 February 2022 14.19 >=20 > Masking of core mask was incorrect. Instead of using 1U for shifting, > it > should be using 1LU as the result is assigned to uint64. >=20 > CID 375859: Potentially overflowing expression "1U << app_main_core" > with > type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit > arithmetic, > and then used in a context that expects an expression of type > "uint64_t" > (64 bits, unsigned). >=20 > Coverity issue: 375859 >=20 > Signed-off-by: Megha Ajmera > --- > examples/qos_sched/args.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/examples/qos_sched/args.c b/examples/qos_sched/args.c > index 10ca7bea61..44f2f5640e 100644 > --- a/examples/qos_sched/args.c > +++ b/examples/qos_sched/args.c > @@ -433,7 +433,7 @@ app_parse_args(int argc, char **argv) > return -1; > } > } > - app_used_core_mask |=3D 1u << app_main_core; > + app_used_core_mask |=3D 1lu << app_main_core; Still wrong on 32 bit platforms, where long unsigned int is still 32 = bits. Use this instead: app_used_core_mask |=3D RTE_BIT64(app_main_core); Ref: https://elixir.bootlin.com/dpdk/latest/source/lib/eal/include/rte_bitops.= h#L26 >=20 > if ((app_used_core_mask !=3D app_eal_core_mask()) || > (app_main_core !=3D rte_get_main_lcore())) { > -- > 2.25.1 >=20