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 15B8942410 for ; Wed, 18 Jan 2023 17:11:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D449427EB; Wed, 18 Jan 2023 17:11:24 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id A5DEC400D6; Wed, 18 Jan 2023 17:11:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674058282; x=1705594282; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=LC+r+Wp3yjLIkqmgeonPgXrogug30MSQ8Uu0ZXWY3q0=; b=kVCdktXrfNLbg++v0j7xTtd1FE/ppEB5SHs9OSTSWungL84CR+Xs8Ozt R8GHDkDIc2K6xreRY6LwB+5o8ova30zirvUGUF+DLX+rUCnS4af+/J2/M UpjL69h0cVTpViYqXtRvlKQNqIZbmVTvULsOGNNTdr3nXKVPKY59n08kP WZFGP9MqeCDgvYzj86JyEwIh+/EdrjIHxuwvaOsiFssBZRzqgnUrZa5Np RRD8gFrlJ5zyT39Lvz0jXTr5mjweFCnOskdKJXYHYIaBbttLVnrZ/HCLO augG2BxTKlJyARimQCFdMsvmAGV0zCf796s3L585zyRqeGIgswbjMh7mG A==; X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="387368281" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="387368281" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 08:11:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="728257940" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="728257940" Received: from silpixa00401459.ir.intel.com (HELO silpixa00401459.ger.corp.intel.com) ([10.237.222.64]) by fmsmga004.fm.intel.com with ESMTP; 18 Jan 2023 08:11:19 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Olivier Matz , Bruce Richardson , stable@dpdk.org Subject: [PATCH] examples/cmdline: fix build error with gcc 12 Date: Wed, 18 Jan 2023 16:11:11 +0000 Message-Id: <20230118161111.11710-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org 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; -- 2.34.1