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 DDF9F42410; Wed, 18 Jan 2023 19:53:43 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8223840223; Wed, 18 Jan 2023 19:53:43 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2053.outbound.protection.outlook.com [40.107.243.53]) by mails.dpdk.org (Postfix) with ESMTP id DC3AE400D6; Wed, 18 Jan 2023 19:53:41 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ixg46T2ExQ+UO2GSBl3KGShh5zlMqCZoy+uLmax8Rse3GT+/CiPpWiTjNvNVfHcnQBH+N23c6lgLlhCr6fvYHNbxyJAmMXTw81KX91koR80O/vTr3OcUfe7hJkvo7VYEr1Hhqy22K0RK5o4jtJpgeltKyOFZ+ZEI/F+4SSceLd5ibda/+ScoAoSa3MDQ3A2Jzw/Xq6meV2MTtA/R3CGVze+0sggVWFxvykyVUPiTqRsg3P33ins59c8bXeCZMG7b5KcC1tMgE+hBjn0f5I2GizIaKuLOLdxLai4NztG0B0ke9k9f0Pxtr4ocnpN/NqZ4M9TugIfAbj+MeLFszh7RiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=M2FmF/euzYwaiR2VzErJ7V8mcbjylClwjALA5+0SGo0=; b=hfaWwJ+05OZ0hqc1Ku2ee4QkrJBMdo4IrC1CBRFPCTejvsnSQYPkPx9JrtBmy9rV7k8kowwsjrNkdIcQd3qFXs4BKY3r9Ry3ZWG2OYbf94tD6ouViCD99WgnHiMWNikCED03z+AY0K5id+tHRyGpKOWlUA7xebUgYPEfQwIVKshguy4L6NQTPrni36OYLAm1c6kXlYTf3lADgzf+/rPHN52nGRrsX/IbEMSiHenx6ALFMIkS7O6yp5VusWxzr6KGax2642owQmNOH0sljpFK9C8u3PgYglYKztxWHGoE2tUl8S/rMJxSY6+JNvtkK59/lt4MnUog2RExelO7iHAuIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M2FmF/euzYwaiR2VzErJ7V8mcbjylClwjALA5+0SGo0=; b=FX5tMD/Xk5u5bIm69dVpPOwglOBKehYEOZg2SbJtiaDf/IPI1Nkz4vLkY1CeTwNwvo82t6lO5bHJwKsU3t52sDbWRGwS+TRUqPCiwTEN136LW7faedw7K6MHQcUS3FuaN6oEEWVn56mdxUHnQCebQuqnP4ssKwMzxeJqu8J5/FU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by MN2PR12MB4549.namprd12.prod.outlook.com (2603:10b6:208:268::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Wed, 18 Jan 2023 18:53:39 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::4807:1f44:5e04:e05a]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::4807:1f44:5e04:e05a%8]) with mapi id 15.20.6002.024; Wed, 18 Jan 2023 18:53:39 +0000 Message-ID: <3dbc9f6b-9efe-5855-aa8c-37513d823db3@amd.com> Date: Wed, 18 Jan 2023 18:53:33 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US To: Bruce Richardson , dev@dpdk.org Cc: Olivier Matz , stable@dpdk.org References: <20230118161111.11710-1-bruce.richardson@intel.com> From: Ferruh Yigit Subject: Re: [PATCH] examples/cmdline: fix build error with gcc 12 In-Reply-To: <20230118161111.11710-1-bruce.richardson@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P265CA0319.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a4::19) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|MN2PR12MB4549:EE_ X-MS-Office365-Filtering-Correlation-Id: a31a09db-f83d-47e3-7e27-08daf9854fc2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FfALHX/68u6XTgkXUvbAUlhB6qNO2QkWTResGwdXQChGhz8WZYNIjvQbuSPbO9M68rs7wOTctkE+psPwjRHLD//VUEPuoKk3Hq7OgHXJ+tfPZ4WwlNP1R2rYh+wKLYR2I5JPVGoFkCFVVdAtlREydwj+x3oHJb9zer47x0AP60z0OTx+pjXv/qK0fwXJ3/zDz2fwgpgAbwE8xaAYJ8yAVHibQKI9OKrNZi1r1oNb/zCuc6vz4ESVG3VdXyI7xfrRdAKmRCjyhuNuHJ8sskpoPQlRHNNi5UypNdVcFgwp9Bfj0LNEzkCKCzk2qU7tXPFhV46UcW9bLuJ6VNN8WtG65WcP2hk9ZX/OAsKCp7xmpoC2QvnObI2hbIQsOW3FiozzCwtjqEF1akqB+ZsFWM48aWUmML9Kyh7oxlQBDi33GYZXjOFoP/1DiFaDTxx3UDqjXfeUaGmlyBWfRkiaMigQzSmi9C2nEHxFzv3iC9vlfr8N9UvlHEr2XR1lc4e0RFroQAmIUqZXyN9+H5p1rXOVYzHPMUdKXVx3VFKvl91Ycz+iP8QLFIZiZ1iSwebAtgvYfq2JTRYoDFmB4JAqNU8wKOflCGYilBupGJFLW48NCWWj5S7PN701fw+O3di0oypkIcpo/GLq6bAMMXPyaIlRb7fxR+oVS9CWxmOOS/Rcqc33HSsyBgFU6YvZdxDfa2qPeQB3hkrW54ac80CrjOPZiYoChVS1iA0Nes/fmMygGGM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(39860400002)(366004)(136003)(451199015)(31686004)(36756003)(44832011)(478600001)(86362001)(66946007)(31696002)(8936002)(4326008)(5660300002)(66476007)(66556008)(2906002)(8676002)(83380400001)(38100700002)(6486002)(316002)(6512007)(6666004)(41300700001)(26005)(53546011)(2616005)(186003)(6506007)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NlpEWFFOM0R4cDExaXlqRWlJSExUbEFiTnVXcU91a1k1NWR4VWFlVlBKSlNo?= =?utf-8?B?RjlPVUozMmU1eGFTTEtmT0UzSFNHdHc2Y3hKdStGa0RmS3Z4V05MeDRXVGFv?= =?utf-8?B?SEcxQkRlOXlrWG43U0kyY0hkRHJmOE5SWnVvQjd0Wi9YUU5KdTcyNGluY1Fr?= =?utf-8?B?UzE0Z2tVK2xhaUo2R2o0NUtHOS9HWHd4MklWclhOVmttNkJmL0FNeXNEaXp5?= =?utf-8?B?bzFrRDlxZVRDS2N1eC82VGxpbzBFYkltVE5WMXRxVWYweEYxVjI2c3ZybHFk?= =?utf-8?B?RXhLakFyY1NGVFlVYmlGNnU2MDREOXQ2TkY2cXBuVWdwdk1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q?CWQCCd2ZmR5dX8OGqZlUF37Vt?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a31a09db-f83d-47e3-7e27-08daf9854fc2 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 18:53:39.5302 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3CLboBWpZ+EA3kMEH2bzhXgaWXtAUySmgu+u2WeeHj3Gi9epU2XUwznonEG/Vt0Q X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4549 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 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: diff --git a/examples/cmdline/parse_obj_list.c b/examples/cmdline/parse_obj_list.c index 959bcd14527e..7b24bfb035d7 100644 --- a/examples/cmdline/parse_obj_list.c +++ b/examples/cmdline/parse_obj_list.c @@ -46,7 +46,7 @@ parse_obj_list(cmdline_parse_token_hdr_t *tk, const char *buf, void *res, token_len++; SLIST_FOREACH(o, tkd->list, next) { - if (token_len != strnlen(o->name, OBJ_NAME_LEN_MAX)) + if (token_len != strnlen(o->name, STR_TOKEN_SIZE)) continue; if (strncmp(buf, o->name, token_len)) continue; @@ -91,7 +91,7 @@ int complete_get_elt_obj_list(cmdline_parse_token_hdr_t *tk, if (!o) return -1; - len = strnlen(o->name, OBJ_NAME_LEN_MAX); + len = strnlen(o->name, STR_TOKEN_SIZE); if ((len + 1) > size) return -1; diff --git a/examples/cmdline/parse_obj_list.h b/examples/cmdline/parse_obj_list.h index 6516d3e2c236..ba234601f106 100644 --- a/examples/cmdline/parse_obj_list.h +++ b/examples/cmdline/parse_obj_list.h @@ -12,12 +12,11 @@ #include #include - -#define OBJ_NAME_LEN_MAX 64 +#include struct object { SLIST_ENTRY(object) next; - char name[OBJ_NAME_LEN_MAX]; + cmdline_fixed_string_t name; cmdline_ipaddr_t ip; };