Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5614584img; Wed, 27 Mar 2019 11:45:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4oMXc0zkueKd1d2TIItYtZ9lEpufyPb0mboLYioFgmoF9eVeat81L4TGOhqaW7d63WMrz X-Received: by 2002:a17:902:407:: with SMTP id 7mr38728282ple.62.1553712304049; Wed, 27 Mar 2019 11:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553712304; cv=none; d=google.com; s=arc-20160816; b=eC9kNJMn2TUNvVaanAuVn+4SWd+kwhGF45aVY1O2Iyj/1SfMF1M08QMtss/GC4OP1P C0vjH/JGEfiEFurYz3XaAspsn0kgkPWSj8SuFiI1f21oar3lTswmrSvIB495LA8MSA9x xQZ9Df7X6/Su6eczP0cQkoBDD0ZaompVkyOBZuoD6O12GDpOtxMbrzPWFbkyhro/AMtE DCUZgvTEICJ8YOAjMbeOKg1HTSrafE95N90TlgQ6UYfsO5Yx06rzp0qSv5UKqoc3dugB HtxPuD+NKIXsxq9F3VlZG3Iu8HlfRprInvkVq2FUq/HQ5ffhLDqh6lQe9nmuQmTGoSF0 ToZg== 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=pDLYQcKZLGJtqopbMNSnH0/v0XEwTI9Nj0YD5M20vW8=; b=dNlRk2gQIJ6ksIiNIpT/KYf0BvMoe3x1mrm7W1U0yGEgFv9328xbht++9vduxdQdW3 QTtAKK303kCgmzFYzP0fmcS0B+7mKg1TOVz+A30yae5CogdOGYwESdyEFIAfRiDnHcf5 Fa9MMYyyYZOwt7iPPjN+8aP0bejPsvPaCpI7fZtEI2jiuTAIMfQubWCfSvExwnRYyV/X YRGX9cL4Zsbyq5qfxPDKK85I2b7lIJ4y9IFn8iy7I69c5VIaJPWT0xW9NXVBDKuahENi KnEGij4T6FKPNfmD51pFRAmrp6o3rB9ZnJJw7L3gkEiEc8scYX/dzd+iIg7o90iIZlge uk1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jslJmU5K; 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 t21si10543183plr.366.2019.03.27.11.44.48; Wed, 27 Mar 2019 11:45:04 -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=jslJmU5K; 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 S2391977AbfC0Snc (ORCPT + 99 others); Wed, 27 Mar 2019 14:43:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:39528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390632AbfC0SVg (ORCPT ); Wed, 27 Mar 2019 14:21:36 -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 D639E2082F; Wed, 27 Mar 2019 18:21:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710895; bh=TblNBVOkdAhOPwWf2nktlqjhN4Ftu9aCTyBhrGow1vo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jslJmU5KXn3OY1JPUIKmYGyb9+bKl63qX1AXZwm4zaUPT3Hv5cBaP+OWeCDBaVmdK voBw5gvsgklKSrvyv7s+9dJYO5cyA51W8IBe9DOlxSnu8NJn2X8J9FVXhOLhrKrOq0 WuFC1cYzFPi/c34Jl4R1Y8rnLAI5p/b0OJ1CZVcs= 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 4.9 33/87] mlxsw: spectrum: Avoid -Wformat-truncation warnings Date: Wed, 27 Mar 2019 14:19:46 -0400 Message-Id: <20190327182040.17444-33-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-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 22a5916e477e..cc847e0cac2d 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -1565,7 +1565,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; } @@ -1576,7 +1576,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