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