From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id AD888A04C0;
	Fri,  9 Oct 2020 13:24:31 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 9420B1D51E;
	Fri,  9 Oct 2020 13:21:26 +0200 (CEST)
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by dpdk.org (Postfix) with ESMTP id 097E31D454;
 Fri,  9 Oct 2020 13:21:22 +0200 (CEST)
IronPort-SDR: Oat9njroNccuriCDzyCqbfypnpUGQb3aCf+IICdjD8A+hBIR8X/mDjW6+w56NTwfSKrFnuPaUp
 Fy8UOR0akhug==
X-IronPort-AV: E=McAfee;i="6000,8403,9768"; a="162010386"
X-IronPort-AV: E=Sophos;i="5.77,354,1596524400"; d="scan'208";a="162010386"
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga004.fm.intel.com ([10.253.24.48])
 by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 09 Oct 2020 04:21:20 -0700
IronPort-SDR: QAgsWIV0uJx6uxoEviFP9HspUw9JXkkt61wOQc0OmpkqIBtEotVl8d3KiRSC4OetXqQVGuqguo
 TM2uyUEtmkyA==
X-IronPort-AV: E=Sophos;i="5.77,354,1596524400"; d="scan'208";a="343779373"
Received: from rnicolau-mobl1.ger.corp.intel.com (HELO [10.252.17.210])
 ([10.252.17.210])
 by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 09 Oct 2020 04:21:19 -0700
To: Bruce Richardson <bruce.richardson@intel.com>, dev@dpdk.org
Cc: stable@dpdk.org, Anatoly Burakov <anatoly.burakov@intel.com>
References: <20200814110045.217724-1-bruce.richardson@intel.com>
 <20200821171017.50531-1-bruce.richardson@intel.com>
 <20200821171017.50531-5-bruce.richardson@intel.com>
From: "Nicolau, Radu" <radu.nicolau@intel.com>
Message-ID: <06488cc8-1923-7885-10df-ef83b755a2c0@intel.com>
Date: Fri, 9 Oct 2020 12:21:16 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101
 Thunderbird/68.12.1
MIME-Version: 1.0
In-Reply-To: <20200821171017.50531-5-bruce.richardson@intel.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Content-Language: en-GB
Subject: Re: [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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>


On 8/21/2020 6:10 PM, Bruce Richardson wrote:
> 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 <bruce.richardson@intel.com>
> ---
Acked-by: Radu Nicolau <radu.nicolau@intel.com>