Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5651516img; Wed, 27 Mar 2019 12:28:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZemQMkPrKsOcDaaJYiVBhwfcH+hPPnwaM4u19AmPFsYKFwBIn+mBGAznw/f/CKa8BqgbU X-Received: by 2002:a65:6108:: with SMTP id z8mr22112247pgu.106.1553714904661; Wed, 27 Mar 2019 12:28:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714904; cv=none; d=google.com; s=arc-20160816; b=dzghbmZmHIKmpB86Ht/Z6HizwBIMIqa1N/J0fPovkhB+RgTYC/cAdj/TB6lROckecd k1tOxezTuRkHRLyOjb8AG9FIq4F06GCPHbfdgkYZpytKSHqDPKS49oUKQLGG4z36eO26 d1BtBUoLxwrZ66HcHmHBrIVaIghpjlIan9ZcgpMgt1yazWY5C9ZqxUI3EN7WWUBEVbnZ szXlCOeYofJpklg6/9Dn3rLGHu0Rn7NAob7SIiqN4h3eod1lm73uPCm9sPlPE7m7t2jO BxiNqhbOq6Gly3FuHiRtB15Xtw2TtcT/SdnCOq3ucxiU628UTYpb65hScW8iQR9FUItp VC4A== 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=XLKsP+vffZDO4z/8NBJ/rvSia7I5TnIFXH15NkvWzF0=; b=vxxHRFFpuCrdTSuMjWsNn0AKFOX3rlzugG5AvoWkMZ68Nmf3Kqzpf9DCuk6xHV8u24 dC+ZbtQZQg84NZxSEoqI01Y3adHTFNaIEckEb9zUMQFJKeyQf2UzsY/kX3ahTZp5B3ka enIDwy1FOWfnkrCYgZ5elIFwZwc2Ycg5/5lGSQ10JgdSnQbzzqqLkaejV2wc70ZjcZ1t hrZwfCL3u0sf7MAFmDgSah5fLl5xmJHOxVnSisvla3KBURK+ar6maz9C5t4VKuYNQ2Gn S9PbXEfJObzhQT8Q8E9xsrdXwcSN5zBB+WunG8TW38LjBxcScfYdFOQBE0QjawjEm5Jd CBuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zuuvnBgr; 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 n2si19855897plp.341.2019.03.27.12.28.09; Wed, 27 Mar 2019 12:28:24 -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=zuuvnBgr; 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 S2387570AbfC0SFE (ORCPT + 99 others); Wed, 27 Mar 2019 14:05:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:45892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387515AbfC0SE5 (ORCPT ); Wed, 27 Mar 2019 14:04:57 -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 3596621738; Wed, 27 Mar 2019 18:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709897; bh=u2gYrfJBu25SovInffio7GBUBKv8Fo1qUfGtX/mMjKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zuuvnBgrwA2+kHchUr4d6L3r7asylkRf+7IFlKMKE4q1cb72WMiCMrZ26W6zNeoYV m3dC2HvaHc8W+3+V39HA60SZVG/LsrS4ySOPRu2IIHo1vFlQNKd+V/b6MOlRTZIJNd GR8FLOBpTsFf0MD2AXR/NmksdVTCOdEAFn4ioick= 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, xdp-newbies@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 095/262] veth: Fix -Wformat-truncation Date: Wed, 27 Mar 2019 13:59:10 -0400 Message-Id: <20190327180158.10245-95-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 abdf47aab4123ece48877cab4153db44fe4dc340 ] Provide a precision hint to snprintf() in order to eliminate a -Wformat-truncation warning provided below. A maximum of 11 characters is allowed to reach a maximum of 32 - 1 characters given a possible maximum value of queues using up to UINT_MAX which occupies 10 characters. Incidentally 11 is the number of characters for "xdp_packets" which is the largest string we append. drivers/net/veth.c: In function 'veth_get_strings': drivers/net/veth.c:118:47: warning: '%s' directive output may be truncated writing up to 31 bytes into a region of size between 12 and 21 [-Wformat-truncation=] snprintf(p, ETH_GSTRING_LEN, "rx_queue_%u_%s", ^~ drivers/net/veth.c:118:5: note: 'snprintf' output between 12 and 52 bytes into a destination of size 32 snprintf(p, ETH_GSTRING_LEN, "rx_queue_%u_%s", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ i, veth_rq_stats_desc[j].desc); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/veth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index f412ea1cef18..b203d1867959 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -115,7 +115,8 @@ static void veth_get_strings(struct net_device *dev, u32 stringset, u8 *buf) p += sizeof(ethtool_stats_keys); for (i = 0; i < dev->real_num_rx_queues; i++) { for (j = 0; j < VETH_RQ_STATS_LEN; j++) { - snprintf(p, ETH_GSTRING_LEN, "rx_queue_%u_%s", + snprintf(p, ETH_GSTRING_LEN, + "rx_queue_%u_%.11s", i, veth_rq_stats_desc[j].desc); p += ETH_GSTRING_LEN; } -- 2.19.1