naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

Blame SOURCES/0150-tc-m_xt-Fix-indenting.patch

4aca6e
From 23def97f419f0cc00baf8d427b83f3cf45d3f6be Mon Sep 17 00:00:00 2001
4aca6e
From: Phil Sutter <psutter@redhat.com>
4aca6e
Date: Tue, 4 Apr 2017 16:21:45 +0200
4aca6e
Subject: [PATCH] tc: m_xt: Fix indenting
4aca6e
4aca6e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1326726
4aca6e
Upstream Status: iproute2.git commit f1a7c7d8301e9
4aca6e
Conflicts: Changes in context and replaced code due to missing upstream
4aca6e
           commit 32a121cba2579 ("tc: code cleanup").
4aca6e
4aca6e
commit f1a7c7d8301e9dcead8f8c0d28e7f1587c0cd3cc
4aca6e
Author: Phil Sutter <phil@nwl.cc>
4aca6e
Date:   Fri Jun 10 13:42:02 2016 +0200
4aca6e
4aca6e
    tc: m_xt: Fix indenting
4aca6e
4aca6e
    By exiting early if xtables_find_target() fails, one indenting level can
4aca6e
    be dropped. Some of the wrongly indented code then happens to sit at the
4aca6e
    right spot by accident which is why this patch is smaller than expected.
4aca6e
4aca6e
    Signed-off-by: Phil Sutter <phil@nwl.cc>
4aca6e
---
4aca6e
 tc/m_xt.c | 54 ++++++++++++++++++++++++++----------------------------
4aca6e
 1 file changed, 26 insertions(+), 28 deletions(-)
4aca6e
4aca6e
diff --git a/tc/m_xt.c b/tc/m_xt.c
4aca6e
index f0efd28..02ac4dd 100644
4aca6e
--- a/tc/m_xt.c
4aca6e
+++ b/tc/m_xt.c
4aca6e
@@ -160,12 +160,15 @@ static int parse_ipt(struct action_util *a,int *argc_p,
4aca6e
 		switch (c) {
4aca6e
 		case 'j':
4aca6e
 			m = xtables_find_target(optarg, XTF_TRY_LOAD);
4aca6e
-			if (NULL != m) {
4aca6e
+			if (!m) {
4aca6e
+				fprintf(stderr, " failed to find target %s\n\n", optarg);
4aca6e
+				return -1;
4aca6e
+			}
4aca6e
 
4aca6e
-				if (0 > build_st(m, NULL)) {
4aca6e
-					printf(" %s error \n", m->name);
4aca6e
-					return -1;
4aca6e
-				}
4aca6e
+			if (build_st(m, NULL) < 0) {
4aca6e
+				printf(" %s error\n", m->name);
4aca6e
+				return -1;
4aca6e
+			}
4aca6e
 #if (XTABLES_VERSION_CODE >= 6)
4aca6e
 			opts = xtables_options_xfrm(tmp_tcipt_globals.orig_opts,
4aca6e
 						    tmp_tcipt_globals.opts,
4aca6e
@@ -181,22 +184,18 @@ static int parse_ipt(struct action_util *a,int *argc_p,
4aca6e
 				return -1;
4aca6e
 			} else
4aca6e
 				tmp_tcipt_globals.opts = opts;
4aca6e
-			} else {
4aca6e
-				fprintf(stderr," failed to find target %s\n\n", optarg);
4aca6e
-				return -1;
4aca6e
-			}
4aca6e
 			ok++;
4aca6e
 			break;
4aca6e
 
4aca6e
 		default:
4aca6e
 			memset(&fw, 0, sizeof (fw));
4aca6e
 #if (XTABLES_VERSION_CODE >= 6)
4aca6e
-		if (m != NULL && m->x6_parse != NULL ) {
4aca6e
-			xtables_option_tpcall(c, argv, 0 , m, NULL);
4aca6e
+			if (m != NULL && m->x6_parse != NULL) {
4aca6e
+				xtables_option_tpcall(c, argv, 0, m, NULL);
4aca6e
 #else
4aca6e
-		if (m != NULL && m->parse != NULL ) {
4aca6e
-			m->parse(c - m->option_offset, argv, 0, &m->tflags,
4aca6e
-				 NULL, &m->t);
4aca6e
+			if (m != NULL && m->parse != NULL) {
4aca6e
+				m->parse(c - m->option_offset, argv, 0,
4aca6e
+				         &m->tflags, NULL, &m->t);
4aca6e
 #endif
4aca6e
 			} else {
4aca6e
 				fprintf(stderr,"failed to find target %s\n\n", optarg);
4aca6e
@@ -335,11 +334,15 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
4aca6e
 		struct xtables_target *m = NULL;
4aca6e
 		t = RTA_DATA(tb[TCA_IPT_TARG]);
4aca6e
 		m = xtables_find_target(t->u.user.name, XTF_TRY_LOAD);
4aca6e
-		if (NULL != m) {
4aca6e
-			if (0 > build_st(m, t)) {
4aca6e
-				fprintf(stderr, " %s error \n", m->name);
4aca6e
-				return -1;
4aca6e
-			}
4aca6e
+		if (!m) {
4aca6e
+			fprintf(stderr, " failed to find target %s\n\n",
4aca6e
+				t->u.user.name);
4aca6e
+			return -1;
4aca6e
+		}
4aca6e
+		if (build_st(m, t) < 0) {
4aca6e
+			fprintf(stderr, " %s error\n", m->name);
4aca6e
+			return -1;
4aca6e
+		}
4aca6e
 
4aca6e
 #if (XTABLES_VERSION_CODE >= 6)
4aca6e
 		opts = xtables_options_xfrm(tmp_tcipt_globals.orig_opts,
4aca6e
@@ -351,16 +354,11 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
4aca6e
 					     m->extra_opts,
4aca6e
 					     &m->option_offset);
4aca6e
 #endif
4aca6e
-	if (opts == NULL) {
4aca6e
-		fprintf(stderr, " failed to find additional options for target %s\n\n", optarg);
4aca6e
-		return -1;
4aca6e
-	} else
4aca6e
-		tmp_tcipt_globals.opts = opts;
4aca6e
-		} else {
4aca6e
-			fprintf(stderr, " failed to find target %s\n\n",
4aca6e
-				t->u.user.name);
4aca6e
+		if (opts == NULL) {
4aca6e
+			fprintf(stderr, " failed to find additional options for target %s\n\n", optarg);
4aca6e
 			return -1;
4aca6e
-		}
4aca6e
+		} else
4aca6e
+			tmp_tcipt_globals.opts = opts;
4aca6e
 		fprintf(f, "\ttarget ");
4aca6e
 		m->print(NULL, m->t, 0);
4aca6e
 		if (tb[TCA_IPT_INDEX] == NULL) {
4aca6e
-- 
4aca6e
1.8.3.1
4aca6e