Netdev List
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: stephen@networkplumber.org, mlxsw@mellanox.com
Subject: [patch iproute2/net-next] tc: gact: fix control action parsing
Date: Mon,  5 Jun 2017 16:22:03 +0200	[thread overview]
Message-ID: <20170605142203.4535-1-jiri@resnulli.us> (raw)

From: Jiri Pirko <jiri@mellanox.com>

parse_action_control helper does advancing of the arg inside. So don't
do it outside.

Fixes: e67aba559581 ("tc: actions: add helpers to parse and print control actions")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 tc/m_gact.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/tc/m_gact.c b/tc/m_gact.c
index d95aa11..1a25833 100644
--- a/tc/m_gact.c
+++ b/tc/m_gact.c
@@ -90,17 +90,14 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p,
 
 	if (matches(*argv, "gact") == 0) {
 		ok++;
+		argc--;
+		argv++;
 	} else {
 		if (parse_action_control(&argc, &argv, &p.action, false) == -1)
 			usage();
 		ok++;
 	}
 
-	if (ok) {
-		argc--;
-		argv++;
-	}
-
 #ifdef CONFIG_GACT_PROB
 	if (ok && argc > 0) {
 		if (matches(*argv, "random") == 0) {
@@ -120,8 +117,6 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p,
 			if (parse_action_control(&argc, &argv,
 						 &pp.paction, false) == -1)
 				usage();
-			argc--;
-			argv++;
 			if (get_u16(&pp.pval, *argv, 10)) {
 				fprintf(stderr, "Illegal probability val 0x%x\n", pp.pval);
 				return -1;
-- 
2.9.3

                 reply	other threads:[~2017-06-05 14:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20170605142203.4535-1-jiri@resnulli.us \
    --to=jiri@resnulli.us \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.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