]>
Commit | Line | Data |
---|---|---|
ba172962 SL |
1 | From 73e218c7b732e510ad5574d2934430e599349b7c Mon Sep 17 00:00:00 2001 |
2 | From: Florian Fainelli <f.fainelli@gmail.com> | |
3 | Date: Thu, 21 Feb 2019 20:09:26 -0800 | |
4 | Subject: mlxsw: spectrum: Avoid -Wformat-truncation warnings | |
5 | ||
6 | [ Upstream commit ab2c4e2581ad32c28627235ff0ae8c5a5ea6899f ] | |
7 | ||
8 | Give precision identifiers to the two snprintf() formatting the priority | |
9 | and TC strings to avoid producing these two warnings: | |
10 | ||
11 | drivers/net/ethernet/mellanox/mlxsw/spectrum.c: In function | |
12 | 'mlxsw_sp_port_get_prio_strings': | |
13 | drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2132:37: warning: '%d' | |
14 | directive output may be truncated writing between 1 and 3 bytes into a | |
15 | region of size between 0 and 31 [-Wformat-truncation=] | |
16 | snprintf(*p, ETH_GSTRING_LEN, "%s_%d", | |
17 | ^~ | |
18 | drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2132:3: note: 'snprintf' | |
19 | output 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 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
24 | drivers/net/ethernet/mellanox/mlxsw/spectrum.c: In function | |
25 | 'mlxsw_sp_port_get_tc_strings': | |
26 | drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2143:37: warning: '%d' | |
27 | directive output may be truncated writing between 1 and 11 bytes into a | |
28 | region of size between 0 and 31 [-Wformat-truncation=] | |
29 | snprintf(*p, ETH_GSTRING_LEN, "%s_%d", | |
30 | ^~ | |
31 | drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2143:3: note: 'snprintf' | |
32 | output 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 | ||
38 | Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> | |
39 | Reviewed-by: Ido Schimmel <idosch@mellanox.com> | |
40 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
41 | Signed-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 | ||
46 | diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c | |
47 | index 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 | -- | |
69 | 2.19.1 | |
70 |