public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber•org>
To: netdev@vger•kernel.org
Cc: Stephen Hemminger <stephen@networkplumber•org>
Subject: [PATCH 5/5] f_u32: fix compiler gcc-10 compiler warning
Date: Sun, 29 Nov 2020 16:21:35 -0800	[thread overview]
Message-ID: <20201130002135.6537-6-stephen@networkplumber.org> (raw)
In-Reply-To: <20201130002135.6537-1-stephen@networkplumber.org>

With gcc-10 it complains about array subscript error.

f_u32.c: In function ‘u32_parse_opt’:
f_u32.c:1113:24: warning: array subscript 0 is outside the bounds of an interior zero-length array ‘struct tc_u32_key[0]’ [-Wzero-length-bounds]
 1113 |    hash = sel2.sel.keys[0].val & sel2.sel.keys[0].mask;
      |           ~~~~~~~~~~~~~^~~
In file included from tc_util.h:11,
                 from f_u32.c:26:
../include/uapi/linux/pkt_cls.h:253:20: note: while referencing ‘keys’
  253 |  struct tc_u32_key keys[0];
      |

This is because the keys are actually allocated in the second element
of the parent structure.

Simplest way to address the warning is to assign directly to the keys
in the containing structure.

This has always been in iproute2 (pre-git) so no Fixes.

Signed-off-by: Stephen Hemminger <stephen@networkplumber•org>
---
 tc/f_u32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tc/f_u32.c b/tc/f_u32.c
index e0a322d5a11c..2ed5254a40d5 100644
--- a/tc/f_u32.c
+++ b/tc/f_u32.c
@@ -1110,7 +1110,7 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
 				}
 				NEXT_ARG();
 			}
-			hash = sel2.sel.keys[0].val & sel2.sel.keys[0].mask;
+			hash = sel2.keys[0].val & sel2.keys[0].mask;
 			hash ^= hash >> 16;
 			hash ^= hash >> 8;
 			htid = ((hash % divisor) << 12) | (htid & 0xFFF00000);
-- 
2.29.2


  parent reply	other threads:[~2020-11-30  0:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30  0:21 [PATCH 0/5] Fix compiler warnings from GCC-10 Stephen Hemminger
2020-11-30  0:21 ` [PATCH 1/5] devlink: fix uninitialized warning Stephen Hemminger
2020-11-30  0:21 ` [PATCH 2/5] bridge: fix string length warning Stephen Hemminger
2020-11-30  0:21 ` [PATCH 3/5] tc: fix compiler warnings in ip6 pedit Stephen Hemminger
2020-11-30 23:10   ` Petr Machata
2020-11-30  0:21 ` [PATCH 4/5] misc: fix compiler warning in ifstat and nstat Stephen Hemminger
2020-11-30  9:18   ` David Laight
2020-11-30 17:31     ` Stephen Hemminger
2020-11-30  0:21 ` Stephen Hemminger [this message]
2020-11-30 19:21 ` [PATCH 0/5] Fix compiler warnings from GCC-10 Jacob Keller
2020-12-03 16:40 ` patchwork-bot+netdevbpf

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=20201130002135.6537-6-stephen@networkplumber.org \
    --to=stephen@networkplumber$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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