netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: netdev@vger.kernel.org
Subject: [PATCH ethtool 7/7] ioctl: avoid zero length array warning in get_stringset()
Date: Mon,  3 Aug 2020 13:57:24 +0200 (CEST)	[thread overview]
Message-ID: <7158b73b9a8d045a25692b33bee8497d3bd627b7.1596451857.git.mkubecek@suse.cz> (raw)
In-Reply-To: <cover.1596451857.git.mkubecek@suse.cz>

Starting with gcc10, gcc issues a warning about accessing elements of
zero leghth arrays. This is usually fixed by using C99 variable length
arrays but struct ethtool_sset_info is part of kernel UAPI so use an
auxiliary pointer instead.

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 ethtool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ethtool.c b/ethtool.c
index 0f312bdae2bb..c4ad186cd390 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -1632,7 +1632,9 @@ get_stringset(struct cmd_context *ctx, enum ethtool_stringset set_id,
 	sset_info.hdr.reserved = 0;
 	sset_info.hdr.sset_mask = 1ULL << set_id;
 	if (send_ioctl(ctx, &sset_info) == 0) {
-		len = sset_info.hdr.sset_mask ? sset_info.hdr.data[0] : 0;
+		const u32 *sset_lengths = sset_info.hdr.data;
+
+		len = sset_info.hdr.sset_mask ? sset_lengths[0] : 0;
 	} else if (errno == EOPNOTSUPP && drvinfo_offset != 0) {
 		/* Fallback for old kernel versions */
 		drvinfo.cmd = ETHTOOL_GDRVINFO;
-- 
2.28.0


  parent reply	other threads:[~2020-08-03 11:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-03 11:57 [PATCH ethtool 0/7] compiler warnings cleanup, part 1 Michal Kubecek
2020-08-03 11:57 ` [PATCH ethtool 1/7] rename maybe_unused macro to __maybe_unused Michal Kubecek
2020-08-03 11:57 ` [PATCH ethtool 2/7] cable_test: clean up unused parameters Michal Kubecek
2020-08-03 23:59   ` Andrew Lunn
2020-08-03 11:57 ` [PATCH ethtool 3/7] igc: mark unused callback parameter Michal Kubecek
2020-08-03 11:57 ` [PATCH ethtool 4/7] netlink: " Michal Kubecek
2020-08-03 11:57 ` [PATCH ethtool 5/7] netlink: mark unused parameters of bitset walker callbacks Michal Kubecek
2020-08-03 11:57 ` [PATCH ethtool 6/7] netlink: mark unused parameters of parser callbacks Michal Kubecek
2020-08-03 11:57 ` Michal Kubecek [this message]
2020-08-03 13:31 ` [PATCH ethtool 0/7] compiler warnings cleanup, part 1 Andrew Lunn
2020-08-03 13:53   ` Michal Kubecek

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=7158b73b9a8d045a25692b33bee8497d3bd627b7.1596451857.git.mkubecek@suse.cz \
    --to=mkubecek@suse.cz \
    --cc=netdev@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).