From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 018A6A04AF; Fri, 21 Aug 2020 19:11:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E5C691C0B6; Fri, 21 Aug 2020 19:11:04 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id E476B1C112; Fri, 21 Aug 2020 19:11:02 +0200 (CEST) IronPort-SDR: 42oEdc+7vYMs4FeU9lEePjfOUcmmlCE1NuOQXL2Rc3W8y3+1zKmbvmRc27d4CvCOBXBx9pMOv1 NkhSEi1t711w== X-IronPort-AV: E=McAfee;i="6000,8403,9720"; a="219870472" X-IronPort-AV: E=Sophos;i="5.76,338,1592895600"; d="scan'208";a="219870472" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2020 10:11:01 -0700 IronPort-SDR: PaZer7NejMalrDap5Xy9R75zJ4fANtxtqoJFcwbMUI0MTktWnRQ33wKcF7dPalgc6Z9TLks+fW 4QQIEwrYcifg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,338,1592895600"; d="scan'208";a="498037828" Received: from silpixa00399126.ir.intel.com ([10.237.222.56]) by fmsmga006.fm.intel.com with ESMTP; 21 Aug 2020 10:11:00 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , stable@dpdk.org, Anatoly Burakov Date: Fri, 21 Aug 2020 18:10:17 +0100 Message-Id: <20200821171017.50531-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821171017.50531-1-bruce.richardson@intel.com> References: <20200814110045.217724-1-bruce.richardson@intel.com> <20200821171017.50531-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 4/4] examples/mp_server: clear string truncation warning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Compiling with GCC 9.3 on Ubuntu 20.04 gives a warning about possible string truncation when getting the RX queue name: In file included from init.c:36: init.c: In function ‘init’: ../shared/common.h:38:28: warning: ‘%u’ directive output may be truncated writing between 1 and 10 bytes into a region of size 8 [-Wformat-truncation=] 38 | #define MP_CLIENT_RXQ_NAME "MProc_Client_%u_RX" | ^~~~~~~~~~~~~~~~~~~~ ../shared/common.h:52:35: note: in expansion of macro ‘MP_CLIENT_RXQ_NAME’ 52 | snprintf(buffer, sizeof(buffer), MP_CLIENT_RXQ_NAME, id); | ^~~~~~~~~~~~~~~~~~ This is a false positive, as the value of the "id" is limited to 255, being stored in the app as a uint8_t value, removing the possibility of the %u being replaced by anything other then 3 characters max (rather than up to 10 as thought by the compiler). Therefore, the warning can be easily removed by changing the type of the "id" parameter to the local function from "unsigned" to "uint8_t" also, ensuring the compiler is aware of the range limit. Cc: stable@dpdk.org Signed-off-by: Bruce Richardson --- examples/multi_process/client_server_mp/shared/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/multi_process/client_server_mp/shared/common.h b/examples/multi_process/client_server_mp/shared/common.h index 6dd43fcac2..76beca0101 100644 --- a/examples/multi_process/client_server_mp/shared/common.h +++ b/examples/multi_process/client_server_mp/shared/common.h @@ -43,7 +43,7 @@ struct port_info { * Given the rx queue name template above, get the queue name */ static inline const char * -get_rx_queue_name(unsigned id) +get_rx_queue_name(uint8_t id) { /* buffer for return value. Size calculated by %u being replaced * by maximum 3 digits (plus an extra byte for safety) */ -- 2.25.1