Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5581950img; Wed, 27 Mar 2019 11:06:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqybqY+B8iGZ28Cc7LRArq/ZAhvmOaOB/UIW+jXymAaHhUVTfSfZXzqLIU5cu3MjcfceKr35 X-Received: by 2002:a62:1d90:: with SMTP id d138mr1404427pfd.232.1553710005649; Wed, 27 Mar 2019 11:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710005; cv=none; d=google.com; s=arc-20160816; b=gPg42FrPsryTSXv8RIDQ97uOZsqEml9xS0sPM7JaJwOSTr2pm/Btpm1+KyK6BLYUUw 6BtA8+or26X5SZ9RmEAYiXo1C61+uoXuG1Xt3kj6aLDbyTr+hN30LJ09jN8iGIxPNHMD mlx49VTLY6DFNjG3c7ehS1ko+qkOIhXhqsbDHzmbCTsUWpq5ps3T5EzGn1VklxU7j+JF BhYxVjdx6HRfIzaBKPOfhEfEdsj0PT6K9HXL3hpDH9pmcbdVUvMJPCO1VjIOVKAwL4/W xVOO21PXi7NnT27SvLOjtnhtUcPl6AS3WEWqqcNyOHnv+V387lt9CQgaiZfz3+IRrvJz J6tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=I5edd/stD7B38pe1xkCaArRl9t3WNCuNGZQ/1paRQFQ=; b=ZkP8Mj4l4fAHmpBqyNwAIWeklvuD7LnkjEyLmSDBvg+CrjwwsqMktgwwXLs6pPIS2m aVkac+KT9riX7NrGDuT+xNc2CyE4SF6waF9jdD0mwLXHOWMyR1D5zekK61jlfzvmlXLm v8NrDc3+PpkNibICY0GW0ad9glx8zzEJNT5/AFQkGD1sEBMmr5yBo9Tgk0P0bAwMfwrU Q88FREuFo6nHL2lTb5G2Da0Y150uTC3ishsmKBQeIVEtTzFrpCy7BiIoJHBD/ZNa2LKd ssHh9FUkmWGwb1et/QjPmV+CuiCNhSJk5oD183V35GEckBsb2iEDLhln0f/NxYcr3OZC 7xwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dESOzM4V; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f89si21137330plb.20.2019.03.27.11.06.30; Wed, 27 Mar 2019 11:06:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dESOzM4V; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387559AbfC0SFI (ORCPT + 99 others); Wed, 27 Mar 2019 14:05:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:45932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731431AbfC0SFA (ORCPT ); Wed, 27 Mar 2019 14:05:00 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9F15F217D9; Wed, 27 Mar 2019 18:04:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709899; bh=G3lsaZVnsAn9stcRdD1TEO+6ZzGaalYkdpwWE+LwnXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dESOzM4VYyI3V4XOzBXs2Xpg7RrRF/XD7S56m4yQEzeBIyA1rcx2Li+dT4NE/HXBW Ognayso9w1D60e/9RPnpBYaAHfrUGenY8mTX82UymaE7tzOefXF8mz8bA2SrZkiQvF QgTrLVs/kVNP3B4Rc2eQvHnCs+VLWHp2tFH0LGwo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Florian Fainelli , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 097/262] mlxsw: spectrum: Avoid -Wformat-truncation warnings Date: Wed, 27 Mar 2019 13:59:12 -0400 Message-Id: <20190327180158.10245-97-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Fainelli [ 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 Reviewed-by: Ido Schimmel Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 b65e274b02e9..cbdee5164be7 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -2105,7 +2105,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; } @@ -2116,7 +2116,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