]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.34/mlxsw-spectrum-avoid-wformat-truncation-warnings.patch
Linux 4.19.34
[thirdparty/kernel/stable-queue.git] / releases / 4.19.34 / mlxsw-spectrum-avoid-wformat-truncation-warnings.patch
CommitLineData
ba172962
SL
1From 73e218c7b732e510ad5574d2934430e599349b7c Mon Sep 17 00:00:00 2001
2From: Florian Fainelli <f.fainelli@gmail.com>
3Date: Thu, 21 Feb 2019 20:09:26 -0800
4Subject: mlxsw: spectrum: Avoid -Wformat-truncation warnings
5
6[ Upstream commit ab2c4e2581ad32c28627235ff0ae8c5a5ea6899f ]
7
8Give precision identifiers to the two snprintf() formatting the priority
9and TC strings to avoid producing these two warnings:
10
11drivers/net/ethernet/mellanox/mlxsw/spectrum.c: In function
12'mlxsw_sp_port_get_prio_strings':
13drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2132:37: warning: '%d'
14directive output may be truncated writing between 1 and 3 bytes into a
15region of size between 0 and 31 [-Wformat-truncation=]
16 snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
17 ^~
18drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2132:3: note: 'snprintf'
19output between 3 and 36 bytes into a destination of size 32
20 snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
21 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 mlxsw_sp_port_hw_prio_stats[i].str, prio);
23 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24drivers/net/ethernet/mellanox/mlxsw/spectrum.c: In function
25'mlxsw_sp_port_get_tc_strings':
26drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2143:37: warning: '%d'
27directive output may be truncated writing between 1 and 11 bytes into a
28region of size between 0 and 31 [-Wformat-truncation=]
29 snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
30 ^~
31drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2143:3: note: 'snprintf'
32output between 3 and 44 bytes into a destination of size 32
33 snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
34 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35 mlxsw_sp_port_hw_tc_stats[i].str, tc);
36 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37
38Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
39Reviewed-by: Ido Schimmel <idosch@mellanox.com>
40Signed-off-by: David S. Miller <davem@davemloft.net>
41Signed-off-by: Sasha Levin <sashal@kernel.org>
42---
43 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 ++--
44 1 file changed, 2 insertions(+), 2 deletions(-)
45
46diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
47index a12b5710891e..f9bef030ee05 100644
48--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
49+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
50@@ -1988,7 +1988,7 @@ static void mlxsw_sp_port_get_prio_strings(u8 **p, int prio)
51 int i;
52
53 for (i = 0; i < MLXSW_SP_PORT_HW_PRIO_STATS_LEN; i++) {
54- snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
55+ snprintf(*p, ETH_GSTRING_LEN, "%.29s_%.1d",
56 mlxsw_sp_port_hw_prio_stats[i].str, prio);
57 *p += ETH_GSTRING_LEN;
58 }
59@@ -1999,7 +1999,7 @@ static void mlxsw_sp_port_get_tc_strings(u8 **p, int tc)
60 int i;
61
62 for (i = 0; i < MLXSW_SP_PORT_HW_TC_STATS_LEN; i++) {
63- snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
64+ snprintf(*p, ETH_GSTRING_LEN, "%.29s_%.1d",
65 mlxsw_sp_port_hw_tc_stats[i].str, tc);
66 *p += ETH_GSTRING_LEN;
67 }
68--
692.19.1
70