[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20190222132512.GA24455@splinter>
Date: Fri, 22 Feb 2019 13:25:15 +0000
From: Ido Schimmel <idosch@...lanox.com>
To: Florian Fainelli <f.fainelli@...il.com>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"davem@...emloft.net" <davem@...emloft.net>,
Jiri Pirko <jiri@...lanox.com>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next 1/4] mlxsw: spectrum: Avoid -Wformat-truncation
warnings
On Thu, Feb 21, 2019 at 08:09:26PM -0800, Florian Fainelli wrote:
> Give precision identifiers to the two snprintf() formatting the priority
> and TC strings to avoid producing these two warnings:
>
> drivers/net/ethernet/mellanox/mlxsw/spectrum.c: In function
> 'mlxsw_sp_port_get_prio_strings':
> drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2132:37: warning: '%d'
> directive output may be truncated writing between 1 and 3 bytes into a
> region of size between 0 and 31 [-Wformat-truncation=]
> snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
> ^~
> drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2132:3: note: 'snprintf'
> output between 3 and 36 bytes into a destination of size 32
> snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> mlxsw_sp_port_hw_prio_stats[i].str, prio);
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlxsw/spectrum.c: In function
> 'mlxsw_sp_port_get_tc_strings':
> drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2143:37: warning: '%d'
> directive output may be truncated writing between 1 and 11 bytes into a
> region of size between 0 and 31 [-Wformat-truncation=]
> snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
> ^~
> drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2143:3: note: 'snprintf'
> output between 3 and 44 bytes into a destination of size 32
> snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> mlxsw_sp_port_hw_tc_stats[i].str, tc);
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Signed-off-by: Florian Fainelli <f.fainelli@...il.com>
Reviewed-by: Ido Schimmel <idosch@...lanox.com>
Powered by blists - more mailing lists