From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3EF1741CE5; Mon, 20 Feb 2023 12:44:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CE4D943014; Mon, 20 Feb 2023 12:44:29 +0100 (CET) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id B906240395; Mon, 20 Feb 2023 12:44:28 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 0116A3200D57; Mon, 20 Feb 2023 06:44:26 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 20 Feb 2023 06:44:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1676893466; x= 1676979866; bh=rLYDBls/O4+lJjHnW3yBYOj4qfuGfmD2vZEaiTLde6E=; b=G KcLv1jMlZUkLUA15sguYtH7iQ/Oz0xKDnNK/Vxc5vfEZLnzpu9C6zx9ZN8+EAUR1 NeNflNiAo5aHThklaiNn8o4asHCnUsjNxRx1bJIX323ciWy0uhSRzZODgjn7GtCG YyQofEaCr4A7lw7qShURqKfZcCIe5hobKjszyrlf5YU+6zIgJjETs7jOwxG4dLZA 00cKzeBgwcfp3ESnDq80gArI5NDQO1+DJATDOBle2YSqbIgGvB3Xsbp6TZ6jUtVK oB+e5aEybLGG+BhMUf9a39JdsLSeAZ8R+duqIShSP0fuXvd9+oj30qZkxFNQzM9j dCbwbig2cMlYkGH7FrFSQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1676893466; x= 1676979866; bh=rLYDBls/O4+lJjHnW3yBYOj4qfuGfmD2vZEaiTLde6E=; b=A 7js418K1kH8BtoDN3cy2fihYVPbQJzQ4oGnkXoqANyU7Z6JClJBpUrUtEpZ1usnw TmIcWwCNXPI8ITyNEhuVeK/MzF2xyE+IgSPtNtEcrMEbcB+PlgAbZsyKlqfucf/V 431DsgGzmYkflJR99MGfA4p8FWy8IDVFi+2HAEy9a6JW9X5/eZU3zpP4yuDeM/j3 1qhAxrFC9KPRm90/faOLfIa+eIdUYYOeFgTq3Wcjg2ChESkG2q30XLMfqf1zv05I engBDwr8UKzrbET5S7z/QflcIzDB5wk+OOCsB5iI6JwZdXU4I+Wx6xfCMgrKPozR 4KBUQNrs2WR1Uifny+y2Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudejhedgvdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedtjeeiieefhedtfffgvdelteeufeefheeujefgueetfedttdei kefgkeduhedtgfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 20 Feb 2023 06:44:25 -0500 (EST) From: Thomas Monjalon To: Bruce Richardson Cc: Ferruh Yigit , dev@dpdk.org, stable@dpdk.org, Olivier Matz Subject: Re: [PATCH] examples/cmdline: fix build error with gcc 12 Date: Mon, 20 Feb 2023 12:44:24 +0100 Message-ID: <7454783.oDFzTOozpa@thomas> In-Reply-To: References: <20230118161111.11710-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 10/02/2023 12:26, Olivier Matz: > Hi, > > Sorry for the late reply. > > On Thu, Jan 19, 2023 at 08:59:10AM +0000, Bruce Richardson wrote: > > On Wed, Jan 18, 2023 at 06:53:33PM +0000, Ferruh Yigit wrote: > > > On 1/18/2023 4:11 PM, Bruce Richardson wrote: > > > > When building the example without libbsd and using the DPDK-provided > > > > strlcpy function, a compiler warning is emitted by GCC 12 about the copy > > > > of the parsed string into the resulting object. This is because the > > > > source from cmdline library is 128 bytes and the destination buffer is > > > > 64-bytes. > > > > > > > > commands.c: In function 'cmd_obj_add_parsed': > > > > .../__BUILDS/build-x86-generic/install/usr/local/include/rte_string_fns.h:61:24: warning: '%s' directive output may be truncated writing up to 127 bytes into a region of size 64 [-Wformat-truncation=] > > > > 61 | return (size_t)snprintf(dst, size, "%s", src); > > > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > In file included from /usr/include/stdio.h:894, > > > > from commands.c:7: > > > > /usr/include/x86_64-linux-gnu/bits/stdio2.h:71:10: note: '__builtin_snprintf' output between 1 and 128 bytes into a destination of size 64 > > > > > > > > Multiple options are possible to fix this, but the one taken in this > > > > patch is to ensure truncation never occurs by setting the destination > > > > buffer size to be the same as that used by the cmdline library. > > > > > > > > Fixes: af75078fece3 ("first public release") > > > > Cc: stable@dpdk.org > > > > > > > > Signed-off-by: Bruce Richardson > > > > --- > > > > examples/cmdline/parse_obj_list.h | 3 ++- > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/examples/cmdline/parse_obj_list.h b/examples/cmdline/parse_obj_list.h > > > > index 6516d3e2c2..1223ac1e8b 100644 > > > > --- a/examples/cmdline/parse_obj_list.h > > > > +++ b/examples/cmdline/parse_obj_list.h > > > > @@ -12,8 +12,9 @@ > > > > > > > > #include > > > > #include > > > > +#include > > > > > > > > -#define OBJ_NAME_LEN_MAX 64 > > > > +#define OBJ_NAME_LEN_MAX sizeof(cmdline_fixed_string_t) > > > > > > > > struct object { > > > > SLIST_ENTRY(object) next; > > > > > > I confirm it solves the build warning, but what about to get rid of > > > `OBJ_NAME_LEN_MAX` completely if the intentions is to make size same as > > > cmdline library array: > > > > > Sure. > > Another potential fix is just to cast-away [(void)] the return value from > > strlcpy and allow truncation. > > > > Olivier, as maintainer, what is your preferred fix here? > > I think you solution is good enough, given it's a dummy example. > > Acked-by: Olivier Matz > > Ferruh's comment about getting rid of OBJ_NAME_LEN_MAX is right, however > I think in this case we should allocate the string and store a pointer > to this string instead of having a size limited buffer. Applied this simple patch.