From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Florian Fainelli <f.fainelli@gmail.com>,
"David S . Miller" <davem@davemloft.net>,
Sasha Levin <sashal@kernel.org>,
netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 065/192] mlxsw: spectrum: Avoid -Wformat-truncation warnings
Date: Wed, 27 Mar 2019 14:08:17 -0400 [thread overview]
Message-ID: <20190327181025.13507-65-sashal@kernel.org> (raw)
In-Reply-To: <20190327181025.13507-1-sashal@kernel.org>
From: Florian Fainelli <f.fainelli@gmail.com>
[ Upstream commit ab2c4e2581ad32c28627235ff0ae8c5a5ea6899f ]
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@gmail.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index a12b5710891e..f9bef030ee05 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -1988,7 +1988,7 @@ static void mlxsw_sp_port_get_prio_strings(u8 **p, int prio)
int i;
for (i = 0; i < MLXSW_SP_PORT_HW_PRIO_STATS_LEN; i++) {
- snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
+ snprintf(*p, ETH_GSTRING_LEN, "%.29s_%.1d",
mlxsw_sp_port_hw_prio_stats[i].str, prio);
*p += ETH_GSTRING_LEN;
}
@@ -1999,7 +1999,7 @@ static void mlxsw_sp_port_get_tc_strings(u8 **p, int tc)
int i;
for (i = 0; i < MLXSW_SP_PORT_HW_TC_STATS_LEN; i++) {
- snprintf(*p, ETH_GSTRING_LEN, "%s_%d",
+ snprintf(*p, ETH_GSTRING_LEN, "%.29s_%.1d",
mlxsw_sp_port_hw_tc_stats[i].str, tc);
*p += ETH_GSTRING_LEN;
}
--
2.19.1
next prev parent reply other threads:[~2019-03-27 19:06 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190327181025.13507-1-sashal@kernel.org>
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 008/192] net/mlx5: Avoid panic when setting vport rate Sasha Levin
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 009/192] net/mlx5: Avoid panic when setting vport mac, getting vport config Sasha Levin
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 013/192] net: stmmac: Avoid sometimes uninitialized Clang warnings Sasha Levin
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 014/192] enic: fix build warning without CONFIG_CPUMASK_OFFSTACK Sasha Levin
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 015/192] libbpf: force fixdep compilation at the start of the build Sasha Levin
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 041/192] netfilter: nf_tables: check the result of dereferencing base_chain->stats Sasha Levin
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 042/192] netfilter: conntrack: tcp: only close if RST matches exact sequence Sasha Levin
2019-03-27 18:07 ` [PATCH AUTOSEL 4.19 047/192] wil6210: check null pointer in _wil_cfg80211_merge_extra_ies Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 048/192] mt76: fix a leaked reference by adding a missing of_node_put Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 063/192] net: dsa: mv88e6xxx: Add lockdep classes to fix false positive splat Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 064/192] e1000e: Fix -Wformat-truncation warnings Sasha Levin
2019-03-27 18:08 ` Sasha Levin [this message]
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 081/192] mwifiex: don't advertise IBSS features without FW support Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 091/192] mt76: usb: do not run mt76u_queues_deinit twice Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 100/192] iwlwifi: pcie: fix emergency path Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 103/192] selftests: skip seccomp get_metadata test if not real root Sasha Levin
2019-03-27 18:08 ` [PATCH AUTOSEL 4.19 106/192] netfilter: conntrack: fix cloned unconfirmed skb->_nfct race in __nf_conntrack_confirm Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 110/192] ath10k: fix shadow register implementation for WCN3990 Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 118/192] net: marvell: mvpp2: fix stuck in-band SGMII negotiation Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 120/192] net: phy: consider latched link-down status in polling mode Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 127/192] e1000e: fix cyclic resets at link up with active tx Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 128/192] e1000e: Exclude device from suspend direct complete optimization Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 132/192] iwlwifi: mvm: fix RFH config command with >=10 CPUs Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 142/192] mt7601u: bump supported EEPROM version Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 146/192] bpf: fix missing prototype warnings Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 147/192] selftests/bpf: skip verifier tests for unsupported program types Sasha Levin
2019-03-27 18:09 ` [PATCH AUTOSEL 4.19 163/192] Bluetooth: Verify that l2cap_get_conf_opt provides large enough buffer Sasha Levin
2019-03-27 18:10 ` [PATCH AUTOSEL 4.19 171/192] netfilter: physdev: relax br_netfilter dependency Sasha Levin
2019-03-27 18:10 ` [PATCH AUTOSEL 4.19 180/192] brcmfmac: Use firmware_request_nowarn for the clm_blob Sasha Levin
2019-03-27 18:10 ` [PATCH AUTOSEL 4.19 181/192] wlcore: Fix memory leak in case wl12xx_fetch_firmware failure Sasha Levin
2019-03-27 18:10 ` [PATCH AUTOSEL 4.19 190/192] net: stmmac: Avoid one more sometimes uninitialized Clang warning Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190327181025.13507-65-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).