All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>, petrm@mellanox.com
Subject: [PATCH 3/5] tc: fix compiler warnings in ip6 pedit
Date: Sun, 29 Nov 2020 16:21:33 -0800	[thread overview]
Message-ID: <20201130002135.6537-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20201130002135.6537-1-stephen@networkplumber.org>

Gcc-10 complains about referencing a zero size array.
This occurs because the array of keys is actually in the following
structure which is part of the overall selector.

The original code was safe, but better to just use the key
array directly.

Fixes: 2d9a8dc439ee ("tc: p_ip6: Support pedit of IPv6 dsfield")
Cc: petrm@mellanox.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/p_ip6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tc/p_ip6.c b/tc/p_ip6.c
index 71660c610c82..83a6ae8183a7 100644
--- a/tc/p_ip6.c
+++ b/tc/p_ip6.c
@@ -82,7 +82,7 @@ parse_ip6(int *argc_p, char ***argv_p,
 		/* Shift the field by 4 bits on success. */
 		if (!res) {
 			int nkeys = sel->sel.nkeys;
-			struct tc_pedit_key *key = &sel->sel.keys[nkeys - 1];
+			struct tc_pedit_key *key = &sel->keys[nkeys - 1];
 
 			key->mask = htonl(ntohl(key->mask) << 4 | 0xf);
 			key->val = htonl(ntohl(key->val) << 4);
-- 
2.29.2


  parent reply	other threads:[~2020-11-30  0:22 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 ` Stephen Hemminger [this message]
2020-11-30 23:10   ` [PATCH 3/5] tc: fix compiler warnings in ip6 pedit 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 ` [PATCH 5/5] f_u32: fix compiler gcc-10 compiler warning Stephen Hemminger
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-4-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=netdev@vger.kernel.org \
    --cc=petrm@mellanox.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.