naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

Blame SOURCES/0090-tc-m_gact-Drop-dead-code.patch

99be8f
From c6e0fc7a5ec0b890c35a3b5d4cc5e1f7794cc47f Mon Sep 17 00:00:00 2001
99be8f
From: Andrea Claudi <aclaudi@redhat.com>
99be8f
Date: Mon, 29 Apr 2019 20:07:22 +0200
99be8f
Subject: [PATCH] tc/m_gact: Drop dead code
99be8f
99be8f
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465646
99be8f
Upstream Status: iproute2.git commit 73aa988868e7e
99be8f
Conflicts: context change due to missing commits:
99be8f
* e67aba5595811 ("tc: actions: add helpers to parse and print control actions")
99be8f
* 18f05d06016d9 ("tc: gact: fix control action parsing")
99be8f
99be8f
commit 73aa988868e7e068b4fc0daaca7cfdb3e07fe744
99be8f
Author: Phil Sutter <phil@nwl.cc>
99be8f
Date:   Thu Aug 17 19:09:31 2017 +0200
99be8f
99be8f
    tc/m_gact: Drop dead code
99be8f
99be8f
    The use of 'ok' variable in parse_gact() is ineffective: The second
99be8f
    conditional increments it either if *argv is 'gact' or if
99be8f
    parse_action_control() doesn't fail (in which case exit() is called).
99be8f
    So this is effectively an unconditional increment and since no decrement
99be8f
    happens anywhere, all remaining checks for 'ok != 0' can be dropped.
99be8f
99be8f
    Signed-off-by: Phil Sutter <phil@nwl.cc>
99be8f
---
99be8f
 tc/m_gact.c | 18 +++++-------------
99be8f
 1 file changed, 5 insertions(+), 13 deletions(-)
99be8f
99be8f
diff --git a/tc/m_gact.c b/tc/m_gact.c
99be8f
index 755a3bee2c2f2..0cb5222fd3817 100644
99be8f
--- a/tc/m_gact.c
99be8f
+++ b/tc/m_gact.c
99be8f
@@ -86,7 +86,6 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p,
99be8f
 {
99be8f
 	int argc = *argc_p;
99be8f
 	char **argv = *argv_p;
99be8f
-	int ok = 0;
99be8f
 	int action = TC_POLICE_RECLASSIFY;
99be8f
 	struct tc_gact p = { .action = TC_POLICE_RECLASSIFY };
99be8f
 #ifdef CONFIG_GACT_PROB
99be8f
@@ -100,25 +99,22 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p,
99be8f
 
99be8f
 
99be8f
 	if (matches(*argv, "gact") == 0) {
99be8f
-		ok++;
99be8f
+		argc--;
99be8f
+		argv++;
99be8f
 	} else {
99be8f
 		action = get_act(&argv);
99be8f
 		if (action != -10) {
99be8f
 			p.action = action;
99be8f
-			ok++;
99be8f
+			argc--;
99be8f
+			argv++;
99be8f
 		} else {
99be8f
 			explain();
99be8f
 			return action;
99be8f
 		}
99be8f
 	}
99be8f
 
99be8f
-	if (ok) {
99be8f
-		argc--;
99be8f
-		argv++;
99be8f
-	}
99be8f
-
99be8f
 #ifdef CONFIG_GACT_PROB
99be8f
-	if (ok && argc > 0) {
99be8f
+	if (argc > 0) {
99be8f
 		if (matches(*argv, "random") == 0) {
99be8f
 			rd = 1;
99be8f
 			NEXT_ARG();
99be8f
@@ -167,15 +163,11 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p,
99be8f
 			}
99be8f
 			argc--;
99be8f
 			argv++;
99be8f
-			ok++;
99be8f
 		} else if (matches(*argv, "help") == 0) {
99be8f
 				usage();
99be8f
 		}
99be8f
 	}
99be8f
 
99be8f
-	if (!ok)
99be8f
-		return -1;
99be8f
-
99be8f
 	tail = NLMSG_TAIL(n);
99be8f
 	addattr_l(n, MAX_MSG, tca_id, NULL, 0);
99be8f
 	addattr_l(n, MAX_MSG, TCA_GACT_PARMS, &p, sizeof(p));
99be8f
-- 
99be8f
2.20.1
99be8f