diff mbox series

[iproute2-next,2/2] tc: replace left side comparison

Message ID 20190124203014.7450-2-stephen@networkplumber.org
State Accepted
Delegated to: David Ahern
Headers show
Series [iproute2-next,1/2] tc: replace print_string with fprintf for error messages | expand

Commit Message

Stephen Hemminger Jan. 24, 2019, 8:30 p.m. UTC
The kernel (and iproute2) don't use the if (NULL == x) style
and instead prefer if (!x)

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/m_action.c | 2 +-
 tc/m_ipt.c    | 3 +--
 tc/m_xt_old.c | 3 +--
 tc/tc_util.c  | 2 +-
 4 files changed, 4 insertions(+), 6 deletions(-)

Comments

David Ahern Jan. 28, 2019, 4:51 p.m. UTC | #1
On 1/24/19 1:30 PM, Stephen Hemminger wrote:
> The kernel (and iproute2) don't use the if (NULL == x) style
> and instead prefer if (!x)
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  tc/m_action.c | 2 +-
>  tc/m_ipt.c    | 3 +--
>  tc/m_xt_old.c | 3 +--
>  tc/tc_util.c  | 2 +-
>  4 files changed, 4 insertions(+), 6 deletions(-)
>

applied to iproute2-next. Thanks
diff mbox series

Patch

diff --git a/tc/m_action.c b/tc/m_action.c
index d5fd5affe703..b5aff3ab4896 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -363,7 +363,7 @@  tc_print_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts)
 
 	parse_rtattr_nested(tb, tot_acts, arg);
 
-	if (tab_flush && NULL != tb[0]  && NULL == tb[1])
+	if (tab_flush && tb[0] && !tb[1])
 		return tc_print_action_flush(f, tb[0]);
 
 	open_json_array(PRINT_JSON, "actions");
diff --git a/tc/m_ipt.c b/tc/m_ipt.c
index b48cc0a9c85f..1d73cb98895a 100644
--- a/tc/m_ipt.c
+++ b/tc/m_ipt.c
@@ -299,9 +299,8 @@  static int parse_ipt(struct action_util *a, int *argc_p,
 		int i;
 
 		for (i = 0; i < rargc; i++) {
-			if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
+			if (!argv[i] || strcmp(argv[i], "action") == 0)
 				break;
-			}
 		}
 		iargc = argc = i;
 	}
diff --git a/tc/m_xt_old.c b/tc/m_xt_old.c
index 313bea61cc7e..25d367785786 100644
--- a/tc/m_xt_old.c
+++ b/tc/m_xt_old.c
@@ -224,9 +224,8 @@  static int parse_ipt(struct action_util *a, int *argc_p,
 		int i;
 
 		for (i = 0; i < rargc; i++) {
-			if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
+			if (!argv[i] || strcmp(argv[i], "action") == 0)
 				break;
-			}
 		}
 		iargc = argc = i;
 	}
diff --git a/tc/tc_util.c b/tc/tc_util.c
index ab717890bb2a..1dfdae141f4d 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -857,7 +857,7 @@  void print_tcstats_attr(FILE *fp, struct rtattr *tb[], char *prefix, struct rtat
 
 	if (tb[TCA_STATS2]) {
 		print_tcstats2_attr(fp, tb[TCA_STATS2], prefix, xstats);
-		if (xstats && NULL == *xstats)
+		if (xstats && !*xstats)
 			goto compat_xstats;
 		return;
 	}