Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1146420imp; Thu, 21 Feb 2019 20:10:30 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ/zHrjSCQ7aywEweusK904H1F/Pv648YrlHPi3pfloISbJnaqgsHjl6ZAKWuNOBvaUHdJE X-Received: by 2002:a62:1112:: with SMTP id z18mr2093637pfi.173.1550808630870; Thu, 21 Feb 2019 20:10:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550808630; cv=none; d=google.com; s=arc-20160816; b=K+S34EUmGa5q1yxRHKAuZKTDhem9RhHfIWqfXurvYxDY78gZOFmZpoi5WZxzjTvPCq gqItX7FHl2TK0uH5ZL0+51jyfRf0E8cx5KhUk1xYG6E4M1TQUlP9I9YdoUZQPCXRRZtL PPHBBkV9JZ2+/UF70bRlrKk+Dj2q4GSj6hcTCBC4Gv0ggE42MI2Y3HK5QNZ+tMbwSWDL s2KhhluegY/c93NT0HPoxC/u9cgp5Ac9EAnynJytbJSEenlP0Fxtg9fJRpcK5PpEODi3 +HQdgXd2rw81hVevGtxRypsQobeeEA4u1VHxb5BPRxNYn3i/rr5ITvNhr7g62eXlN05y 4DZA== 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=1hA0RaDSzpjwvtz0nSJ4G4w3181lotehF1hftLxCAX8=; b=YrjACCV0mqz0VWaBEToF3ne1XX5UvGd/B9U+SPnVSLelfsO/FTe9byGP8y+AB6Rluo hUaBYXR76u7oB0qVZ0vg++WSJ9Sh37ki9DFZt73b7lCb1Z99RA3gVdUhex+SBMCx51h9 WDboO0Xivxw38CGikFOlroETdybpsHuiOoyO3QLQfctUMv4Nndvv4z8JD4B+IHv6Slfx 8ncFlenyDnKpvQx1dAtCpGPzZGGO9gHtuuYXXR0xeqnbpYMnBTh3yu3wEwARffI1Hm3L JAinQBrPeF8VSo4eB6CJmPnYuMhAfSJnuq0kBW39ktemJ+MxcWEDGTdAii82e3y1iTzu tkYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="rz/IOuxQ"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5si357970pgq.193.2019.02.21.20.10.13; Thu, 21 Feb 2019 20:10:30 -0800 (PST) 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=@gmail.com header.s=20161025 header.b="rz/IOuxQ"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726706AbfBVEJr (ORCPT + 99 others); Thu, 21 Feb 2019 23:09:47 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:37481 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbfBVEJr (ORCPT ); Thu, 21 Feb 2019 23:09:47 -0500 Received: by mail-ot1-f66.google.com with SMTP id b3so811686otp.4; Thu, 21 Feb 2019 20:09:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1hA0RaDSzpjwvtz0nSJ4G4w3181lotehF1hftLxCAX8=; b=rz/IOuxQoE5tTPwE0Z5PVA38BdYg9uAuCi/jSyQmXnxqoUuG1HSIrAnzPaO0vZikNJ 5pWHugUc3VNw206wONd/VqzpZ6EozwbdeQfM/T+Uo4OFEM3ZVuVN9htDTfnU4oAZYjvM EKOTF3JAQ0Y4NieBTntLwyH8kq1WlF5z5qMtYOXWW1pDk4Lj5L5iMmMcSeFvPgk5OejN 3i44gdfqZud1nGWKuQvazPJGv/+ji98kBrIrI4YtgakL4UM11Ruq3YhawT6bi0M5fXMS dZh05FJyuw5X45d+7pX/pUhP5yYgRc+02wm5y2IklcuAjGVfC7TI4z0dmtzXRzoI+b5p iXkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1hA0RaDSzpjwvtz0nSJ4G4w3181lotehF1hftLxCAX8=; b=IUlWfMRlWurAzvUxRi/7rf/LDhvQXuRNO9u8gy6RUviZqc/S78pHUzPts53Zvhr+9e PLHe/PTN+xfcmov0hk5iNRMAR5hwx0OLFd69Rconiu6MJpUsffCRkT6iaQywHoMtapIO SEydGJkLZDlFo4x7qDmTtssibr4hJgggp6OpC8OR6igJKmI+yJ66SKmqRzpLcS9FYuLU A/qcmEHp940ox3ePFhYxS+Myh58UAJOLi77Lxvt8FK1k6PgNrNz5KsmLcqNPwgC+JS20 clwDWM7/efKow3aoECQG5aZIMUZJW4oZCIKmabDJSJ8Xn7GHDQ69/VBAIQcWnDlcjy6h 5u6w== X-Gm-Message-State: AHQUAubUIvqbAZkCwypuNbIrO5TarGcvlnZeYdlXZGuMsKUmnYKgGlbI 0FGSg2UpuJV0ha/ZsfJ+Q9VYwGp6 X-Received: by 2002:a05:6830:d8:: with SMTP id x24mr1335217oto.352.1550808585597; Thu, 21 Feb 2019 20:09:45 -0800 (PST) Received: from localhost.localdomain (ip68-228-73-187.oc.oc.cox.net. [68.228.73.187]) by smtp.gmail.com with ESMTPSA id r1sm167836otk.48.2019.02.21.20.09.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 20:09:44 -0800 (PST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: davem@davemloft.net, Florian Fainelli , Jiri Pirko , Ido Schimmel , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 1/4] mlxsw: spectrum: Avoid -Wformat-truncation warnings Date: Thu, 21 Feb 2019 20:09:26 -0800 Message-Id: <20190222040929.16657-2-f.fainelli@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190222040929.16657-1-f.fainelli@gmail.com> References: <20190222040929.16657-1-f.fainelli@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 f018b0607dac..5f6962da8877 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -2129,7 +2129,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; } @@ -2140,7 +2140,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