Skip to contentSkip to conversation

net: netfilter: replace explicit NULL comparison with ! operator

PATCH New Arushi Singhal 1 participant 1 message Mar 29, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: netfilter: replace explicit NULL comparison with ! operator

Replace explicit NULL comparison with ! operator to simplify code.

---
 net/netfilter/ipvs/ip_vs_ctl.c         |  8 ++---
 net/netfilter/ipvs/ip_vs_proto.c       |  8 ++---
 net/netfilter/nf_conntrack_broadcast.c |  2 +-
 net/netfilter/nf_conntrack_core.c      |  2 +-
 net/netfilter/nf_conntrack_ecache.c    |  4 +--
 net/netfilter/nf_conntrack_helper.c    |  4 +--
 net/netfilter/nf_conntrack_proto.c     |  4 +--
 net/netfilter/nf_log.c                 |  2 +-
 net/netfilter/nf_nat_redirect.c        |  2 +-
 net/netfilter/nf_tables_api.c          | 62 +++++++++++++++++-----------------
 net/netfilter/nfnetlink_log.c          |  6 ++--
 net/netfilter/nfnetlink_queue.c        |  8 ++---
 net/netfilter/nft_compat.c             |  4 +--
 net/netfilter/nft_ct.c                 | 10 +++---
 net/netfilter/nft_dynset.c             | 14 ++++----
 net/netfilter/nft_log.c                | 14 ++++----
 net/netfilter/nft_lookup.c             |  2 +-
 net/netfilter/nft_payload.c            |  4 +--
 net/netfilter/nft_set_hash.c           |  4 +--
 net/netfilter/x_tables.c               |  8 ++---
 net/netfilter/xt_TCPMSS.c              |  4 +--
 net/netfilter/xt_addrtype.c            |  2 +-
 net/netfilter/xt_connlimit.c           |  2 +-
 net/netfilter/xt_conntrack.c           |  2 +-
 net/netfilter/xt_hashlimit.c           |  4 +--
 net/netfilter/xt_recent.c              |  6 ++--
 26 files changed, 96 insertions(+), 96 deletions(-)
net/netfilter/ipvs/ip_vs_ctl.c +4 -4
index 5aeb0dde6ccc..32daa0b3797e 100644
@@ -983,7 +983,7 @@ ip_vs_add_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest)
 	dest = ip_vs_lookup_dest(svc, udest->af, &daddr, dport);
 	rcu_read_unlock();
 
-	if (dest != NULL) {
+	if (dest) {
 		IP_VS_DBG(1, "%s(): dest already exists\n", __func__);
 		return -EEXIST;
 	}
@@ -994,7 +994,7 @@ ip_vs_add_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest)
 	 */
 	dest = ip_vs_trash_get_dest(svc, udest->af, &daddr, dport);
 
-	if (dest != NULL) {
+	if (dest) {
 		IP_VS_DBG_BUF(3, "Get destination %s:%u from trash, "
 			      "dest->refcnt=%d, service %u/%s:%u\n",
 			      IP_VS_DBG_ADDR(udest->af, &daddr), ntohs(dport),
@@ -1299,7 +1299,7 @@ ip_vs_add_service(struct netns_ipvs *ipvs, struct ip_vs_service_user_kern *u,
 
 
  out_err:
-	if (svc != NULL) {
+	if (svc) {
 		ip_vs_unbind_scheduler(svc, sched);
 		ip_vs_service_free(svc);
 	}
@@ -2453,7 +2453,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
 
 	switch (cmd) {
 	case IP_VS_SO_SET_ADD:
-		if (svc != NULL)
+		if (svc)
 			ret = -EEXIST;
 		else
 			ret = ip_vs_add_service(ipvs, &usvc, &svc);
net/netfilter/ipvs/ip_vs_proto.c +4 -4
index 8ae480715cea..6ee7fec2ef47 100644
@@ -53,7 +53,7 @@ static int __used __init register_ip_vs_protocol(struct ip_vs_protocol *pp)
 	pp->next = ip_vs_proto_table[hash];
 	ip_vs_proto_table[hash] = pp;
 
-	if (pp->init != NULL)
+	if (pp->init)
 		pp->init(pp);
 
 	return 0;
@@ -77,7 +77,7 @@ register_ip_vs_proto_netns(struct netns_ipvs *ipvs, struct ip_vs_protocol *pp)
 	ipvs->proto_data_table[hash] = pd;
 	atomic_set(&pd->appcnt, 0);	/* Init app counter */
 
-	if (pp->init_netns != NULL) {
+	if (pp->init_netns) {
 		int ret = pp->init_netns(ipvs, pd);
 		if (ret) {
 			/* unlink an free proto data */
@@ -102,7 +102,7 @@ static int unregister_ip_vs_protocol(struct ip_vs_protocol *pp)
 	for (; *pp_p; pp_p = &(*pp_p)->next) {
 		if (*pp_p == pp) {
 			*pp_p = pp->next;
-			if (pp->exit != NULL)
+			if (pp->exit)
 				pp->exit(pp);
 			return 0;
 		}
@@ -124,7 +124,7 @@ unregister_ip_vs_proto_netns(struct netns_ipvs *ipvs, struct ip_vs_proto_data *p
 	for (; *pd_p; pd_p = &(*pd_p)->next) {
 		if (*pd_p == pd) {
 			*pd_p = pd->next;
-			if (pd->pp->exit_netns != NULL)
+			if (pd->pp->exit_netns)
 				pd->pp->exit_netns(ipvs, pd);
 			kfree(pd);
 			return 0;
net/netfilter/nf_conntrack_broadcast.c +1 -1
index 4e99cca61612..a016d47e5a80 100644
@@ -42,7 +42,7 @@ int nf_conntrack_broadcast_help(struct sk_buff *skb,
 
 	rcu_read_lock();
 	in_dev = __in_dev_get_rcu(rt->dst.dev);
-	if (in_dev != NULL) {
+	if (in_dev) {
 		for_primary_ifa(in_dev) {
 			if (ifa->ifa_broadcast == iph->daddr) {
 				mask = ifa->ifa_mask;
net/netfilter/nf_conntrack_core.c +1 -1
index ffb78e5f7b70..282d7ec1acba 100644
@@ -1345,7 +1345,7 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
 	/* It may be an special packet, error, unclean...
 	 * inverse of the return code tells to the netfilter
 	 * core what to do with the packet. */
-	if (l4proto->error != NULL) {
+	if (l4proto->error) {
 		ret = l4proto->error(net, tmpl, skb, dataoff, pf, hooknum);
 		if (ret <= 0) {
 			NF_CT_STAT_INC_ATOMIC(net, error);
net/netfilter/nf_conntrack_ecache.c +2 -2
index da9df2d56e66..11184cae5329 100644
@@ -266,7 +266,7 @@ int nf_conntrack_register_notifier(struct net *net,
 	mutex_lock(&nf_ct_ecache_mutex);
 	notify = rcu_dereference_protected(net->ct.nf_conntrack_event_cb,
 					   lockdep_is_held(&nf_ct_ecache_mutex));
-	if (notify != NULL) {
+	if (notify) {
 		ret = -EBUSY;
 		goto out_unlock;
 	}
@@ -302,7 +302,7 @@ int nf_ct_expect_register_notifier(struct net *net,
 	mutex_lock(&nf_ct_ecache_mutex);
 	notify = rcu_dereference_protected(net->ct.nf_expect_event_cb,
 					   lockdep_is_held(&nf_ct_ecache_mutex));
-	if (notify != NULL) {
+	if (notify) {
 		ret = -EBUSY;
 		goto out_unlock;
 	}
net/netfilter/nf_conntrack_helper.c +2 -2
index 6dc44d9b4190..fda6348a88e5 100644
@@ -224,9 +224,9 @@ int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
 	if (test_bit(IPS_HELPER_BIT, &ct->status))
 		return 0;
 
-	if (tmpl != NULL) {
+	if (tmpl) {
 		help = nfct_help(tmpl);
-		if (help != NULL) {
+		if (help) {
 			helper = help->helper;
 			set_bit(IPS_HELPER_BIT, &ct->status);
 		}
net/netfilter/nf_conntrack_proto.c +2 -2
index 2d6ee1803415..cb1e1593fc82 100644
@@ -307,7 +307,7 @@ int nf_ct_l4proto_register_sysctl(struct net *net,
 	int err = 0;
 
 #ifdef CONFIG_SYSCTL
-	if (pn->ctl_table != NULL) {
+	if (pn->ctl_table) {
 		err = nf_ct_register_sysctl(net,
 					    &pn->ctl_table_header,
 					    "net/netfilter",
@@ -329,7 +329,7 @@ void nf_ct_l4proto_unregister_sysctl(struct net *net,
 				     struct nf_conntrack_l4proto *l4proto)
 {
 #ifdef CONFIG_SYSCTL
-	if (pn->ctl_table_header != NULL)
+	if (pn->ctl_table_header)
 		nf_ct_unregister_sysctl(&pn->ctl_table_header,
 					&pn->ctl_table,
 					pn->users);
net/netfilter/nf_log.c +1 -1
index 8d85a0598b60..fd4cea972bc3 100644
@@ -226,7 +226,7 @@ void nf_log_packet(struct net *net,
 	const struct nf_logger *logger;
 
 	rcu_read_lock();
-	if (loginfo != NULL)
+	if (loginfo)
 		logger = rcu_dereference(loggers[pf][loginfo->type]);
 	else
 		logger = rcu_dereference(net->nf.nf_loggers[pf]);
net/netfilter/nf_nat_redirect.c +1 -1
index d43869879fcf..8bb0a169e640 100644
@@ -100,7 +100,7 @@ nf_nat_redirect_ipv6(struct sk_buff *skb, const struct nf_nat_range *range,
 
 		rcu_read_lock();
 		idev = __in6_dev_get(skb->dev);
-		if (idev != NULL) {
+		if (idev) {
 			list_for_each_entry(ifa, &idev->addr_list, if_list) {
 				newdst = ifa->addr;
 				addr = true;
net/netfilter/nf_tables_api.c +31 -31

242 lines not on this page · raw message

net/netfilter/nfnetlink_log.c +3 -3
index 08247bf7d7b8..e85a4e1da9e9 100644
@@ -683,9 +683,9 @@ nfulnl_log_packet(struct net *net,
 		size += nla_total_size(sizeof(u_int32_t));
 	if (inst->flags & NFULNL_CFG_F_CONNTRACK) {
 		nfnl_ct = rcu_dereference(nfnl_ct_hook);
-		if (nfnl_ct != NULL) {
+		if (nfnl_ct) {
 			ct = nfnl_ct->get_ct(skb, &ctinfo);
-			if (ct != NULL)
+			if (ct)
 				size += nfnl_ct->build_size(ct);
 		}
 	}
@@ -868,7 +868,7 @@ static int nfulnl_recv_config(struct net *net, struct sock *ctnl,
 		}
 	}
 
-	if (cmd != NULL) {
+	if (cmd) {
 		switch (cmd->command) {
 		case NFULNL_CFG_CMD_BIND:
 			if (inst) {
net/netfilter/nfnetlink_queue.c +4 -4
index 3ee0b8a000a4..f23cf318a9f2 100644
@@ -422,9 +422,9 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
 	nfnl_ct = rcu_dereference(nfnl_ct_hook);
 
 	if (queue->flags & NFQA_CFG_F_CONNTRACK) {
-		if (nfnl_ct != NULL) {
+		if (nfnl_ct) {
 			ct = nfnl_ct->get_ct(entskb, &ctinfo);
-			if (ct != NULL)
+			if (ct)
 				size += nfnl_ct->build_size(ct);
 		}
 	}
@@ -1166,7 +1166,7 @@ static int nfqnl_recv_verdict(struct net *net, struct sock *ctnl,
 	nfnl_ct = rcu_dereference(nfnl_ct_hook);
 
 	if (nfqa[NFQA_CT]) {
-		if (nfnl_ct != NULL)
+		if (nfnl_ct)
 			ct = nfqnl_ct_parse(nfnl_ct, nlh, nfqa, entry, &ctinfo);
 	}
 
@@ -1275,7 +1275,7 @@ static int nfqnl_recv_config(struct net *net, struct sock *ctnl,
 		goto err_out_unlock;
 	}
 
-	if (cmd != NULL) {
+	if (cmd) {
 		switch (cmd->command) {
 		case NFQNL_CFG_CMD_BIND:
 			if (queue) {
net/netfilter/nft_compat.c +2 -2
index c21e7eb8dce0..9d314c567ccd 100644
@@ -271,7 +271,7 @@ nft_target_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr)
 	par.target = target;
 	par.targinfo = info;
 	par.family = ctx->afi->family;
-	if (par.target->destroy != NULL)
+	if (par.target->destroy)
 		par.target->destroy(&par);
 
 	nft_xt_put(container_of(expr->ops, struct nft_xt, ops));
@@ -454,7 +454,7 @@ nft_match_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr)
 	par.match = match;
 	par.matchinfo = info;
 	par.family = ctx->afi->family;
-	if (par.match->destroy != NULL)
+	if (par.match->destroy)
 		par.match->destroy(&par);
 
 	nft_xt_put(container_of(expr->ops, struct nft_xt, ops));
net/netfilter/nft_ct.c +5 -5
index 0264258c46fe..a05b4f1100ca 100644
@@ -374,7 +374,7 @@ static int nft_ct_get_init(const struct nft_ctx *ctx,
 	priv->dir = IP_CT_DIR_MAX;
 	switch (priv->key) {
 	case NFT_CT_DIRECTION:
-		if (tb[NFTA_CT_DIRECTION] != NULL)
+		if (tb[NFTA_CT_DIRECTION])
 			return -EINVAL;
 		len = sizeof(u8);
 		break;
@@ -387,19 +387,19 @@ static int nft_ct_get_init(const struct nft_ctx *ctx,
 	case NFT_CT_SECMARK:
 #endif
 	case NFT_CT_EXPIRATION:
-		if (tb[NFTA_CT_DIRECTION] != NULL)
+		if (tb[NFTA_CT_DIRECTION])
 			return -EINVAL;
 		len = sizeof(u32);
 		break;
 #ifdef CONFIG_NF_CONNTRACK_LABELS
 	case NFT_CT_LABELS:
-		if (tb[NFTA_CT_DIRECTION] != NULL)
+		if (tb[NFTA_CT_DIRECTION])
 			return -EINVAL;
 		len = NF_CT_LABELS_MAX_SIZE;
 		break;
 #endif
 	case NFT_CT_HELPER:
-		if (tb[NFTA_CT_DIRECTION] != NULL)
+		if (tb[NFTA_CT_DIRECTION])
 			return -EINVAL;
 		len = NF_CT_HELPER_NAME_LEN;
 		break;
@@ -450,7 +450,7 @@ static int nft_ct_get_init(const struct nft_ctx *ctx,
 		return -EOPNOTSUPP;
 	}
 
-	if (tb[NFTA_CT_DIRECTION] != NULL) {
+	if (tb[NFTA_CT_DIRECTION]) {
 		priv->dir = nla_get_u8(tb[NFTA_CT_DIRECTION]);
 		switch (priv->dir) {
 		case IP_CT_DIR_ORIGINAL:
net/netfilter/nft_dynset.c +7 -7
index 049ad2d9ee66..a0bf5eeab581 100644
@@ -85,7 +85,7 @@ static void nft_dynset_eval(const struct nft_expr *expr,
 		} else if (sexpr == NULL)
 			goto out;
 
-		if (sexpr != NULL)
+		if (sexpr)
 			sexpr->ops->eval(sexpr, regs, pkt);
 
 		if (priv->invert)
@@ -163,7 +163,7 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
 	}
 
 	timeout = 0;
-	if (tb[NFTA_DYNSET_TIMEOUT] != NULL) {
+	if (tb[NFTA_DYNSET_TIMEOUT]) {
 		if (!(set->flags & NFT_SET_TIMEOUT))
 			return -EINVAL;
 		timeout = msecs_to_jiffies(be64_to_cpu(nla_get_be64(
@@ -175,7 +175,7 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
 	if (err < 0)
 		return err;
 
-	if (tb[NFTA_DYNSET_SREG_DATA] != NULL) {
+	if (tb[NFTA_DYNSET_SREG_DATA]) {
 		if (!(set->flags & NFT_SET_MAP))
 			return -EINVAL;
 		if (set->dtype == NFT_DATA_VERDICT)
@@ -188,7 +188,7 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
 	} else if (set->flags & NFT_SET_MAP)
 		return -EINVAL;
 
-	if (tb[NFTA_DYNSET_EXPR] != NULL) {
+	if (tb[NFTA_DYNSET_EXPR]) {
 		if (!(set->flags & NFT_SET_EVAL))
 			return -EINVAL;
 		if (!(set->flags & NFT_SET_ANONYMOUS))
@@ -208,7 +208,7 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
 	nft_set_ext_add_length(&priv->tmpl, NFT_SET_EXT_KEY, set->klen);
 	if (set->flags & NFT_SET_MAP)
 		nft_set_ext_add_length(&priv->tmpl, NFT_SET_EXT_DATA, set->dlen);
-	if (priv->expr != NULL)
+	if (priv->expr)
 		nft_set_ext_add_length(&priv->tmpl, NFT_SET_EXT_EXPR,
 				       priv->expr->ops->size);
 	if (set->flags & NFT_SET_TIMEOUT) {
@@ -226,7 +226,7 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
 	return 0;
 
 err1:
-	if (priv->expr != NULL)
+	if (priv->expr)
 		nft_expr_destroy(ctx, priv->expr);
 	return err;
 }
@@ -237,7 +237,7 @@ static void nft_dynset_destroy(const struct nft_ctx *ctx,
 	struct nft_dynset *priv = nft_expr_priv(expr);
 
 	nf_tables_unbind_set(ctx, priv->set, &priv->binding);
-	if (priv->expr != NULL)
+	if (priv->expr)
 		nft_expr_destroy(ctx, priv->expr);
 }
 
net/netfilter/nft_log.c +7 -7
index 6f6e64423643..41d62f8678df 100644
@@ -60,14 +60,14 @@ static int nft_log_init(const struct nft_ctx *ctx,
 	if (tb[NFTA_LOG_LEVEL] != NULL &&
 	    tb[NFTA_LOG_GROUP] != NULL)
 		return -EINVAL;
-	if (tb[NFTA_LOG_GROUP] != NULL) {
+	if (tb[NFTA_LOG_GROUP]) {
 		li->type = NF_LOG_TYPE_ULOG;
-		if (tb[NFTA_LOG_FLAGS] != NULL)
+		if (tb[NFTA_LOG_FLAGS])
 			return -EINVAL;
 	}
 
 	nla = tb[NFTA_LOG_PREFIX];
-	if (nla != NULL) {
+	if (nla) {
 		priv->prefix = kmalloc(nla_len(nla) + 1, GFP_KERNEL);
 		if (priv->prefix == NULL)
 			return -ENOMEM;
@@ -78,7 +78,7 @@ static int nft_log_init(const struct nft_ctx *ctx,
 
 	switch (li->type) {
 	case NF_LOG_TYPE_LOG:
-		if (tb[NFTA_LOG_LEVEL] != NULL) {
+		if (tb[NFTA_LOG_LEVEL]) {
 			li->u.log.level =
 				ntohl(nla_get_be32(tb[NFTA_LOG_LEVEL]));
 		} else {
@@ -89,7 +89,7 @@ static int nft_log_init(const struct nft_ctx *ctx,
 			goto err1;
 		}
 
-		if (tb[NFTA_LOG_FLAGS] != NULL) {
+		if (tb[NFTA_LOG_FLAGS]) {
 			li->u.log.logflags =
 				ntohl(nla_get_be32(tb[NFTA_LOG_FLAGS]));
 			if (li->u.log.logflags & ~NF_LOG_MASK) {
@@ -100,12 +100,12 @@ static int nft_log_init(const struct nft_ctx *ctx,
 		break;
 	case NF_LOG_TYPE_ULOG:
 		li->u.ulog.group = ntohs(nla_get_be16(tb[NFTA_LOG_GROUP]));
-		if (tb[NFTA_LOG_SNAPLEN] != NULL) {
+		if (tb[NFTA_LOG_SNAPLEN]) {
 			li->u.ulog.flags |= NF_LOG_F_COPY_LEN;
 			li->u.ulog.copy_len =
 				ntohl(nla_get_be32(tb[NFTA_LOG_SNAPLEN]));
 		}
-		if (tb[NFTA_LOG_QTHRESHOLD] != NULL) {
+		if (tb[NFTA_LOG_QTHRESHOLD]) {
 			li->u.ulog.qthreshold =
 				ntohs(nla_get_be16(tb[NFTA_LOG_QTHRESHOLD]));
 		}
net/netfilter/nft_lookup.c +1 -1
index e21aea7e5ec8..47c68b06fea4 100644
@@ -103,7 +103,7 @@ static int nft_lookup_init(const struct nft_ctx *ctx,
 		}
 	}
 
-	if (tb[NFTA_LOOKUP_DREG] != NULL) {
+	if (tb[NFTA_LOOKUP_DREG]) {
 		if (priv->invert)
 			return -EINVAL;
 		if (!(set->flags & NFT_SET_MAP))
net/netfilter/nft_payload.c +2 -2
index 7d699bbd45b0..c324138d5262 100644
@@ -408,8 +408,8 @@ nft_payload_select_ops(const struct nft_ctx *ctx,
 		return ERR_PTR(-EOPNOTSUPP);
 	}
 
-	if (tb[NFTA_PAYLOAD_SREG] != NULL) {
-		if (tb[NFTA_PAYLOAD_DREG] != NULL)
+	if (tb[NFTA_PAYLOAD_SREG]) {
+		if (tb[NFTA_PAYLOAD_DREG])
 			return ERR_PTR(-EINVAL);
 		return &nft_payload_set_ops;
 	}
net/netfilter/nft_set_hash.c +2 -2
index 5f652720fc78..ff0357a289a5 100644
@@ -83,7 +83,7 @@ static bool nft_hash_lookup(const struct net *net, const struct nft_set *set,
 	};
 
 	he = rhashtable_lookup_fast(&priv->ht, &arg, nft_hash_params);
-	if (he != NULL)
+	if (he)
 		*ext = &he->ext;
 
 	return !!he;
@@ -106,7 +106,7 @@ static bool nft_hash_update(struct nft_set *set, const u32 *key,
 	};
 
 	he = rhashtable_lookup_fast(&priv->ht, &arg, nft_hash_params);
-	if (he != NULL)
+	if (he)
 		goto out;
 
 	he = new(set, expr, regs);
net/netfilter/x_tables.c +4 -4
index 14857afc9937..f7f4ac911373 100644
@@ -459,7 +459,7 @@ int xt_check_match(struct xt_mtchk_param *par,
 		       par->match->proto);
 		return -EINVAL;
 	}
-	if (par->match->checkentry != NULL) {
+	if (par->match->checkentry) {
 		ret = par->match->checkentry(par);
 		if (ret < 0)
 			return ret;
@@ -842,7 +842,7 @@ int xt_check_target(struct xt_tgchk_param *par,
 		       par->target->proto);
 		return -EINVAL;
 	}
-	if (par->target->checkentry != NULL) {
+	if (par->target->checkentry) {
 		ret = par->target->checkentry(par);
 		if (ret < 0)
 			return ret;
@@ -1023,7 +1023,7 @@ void xt_free_table_info(struct xt_table_info *info)
 {
 	int cpu;
 
-	if (info->jumpstack != NULL) {
+	if (info->jumpstack) {
 		for_each_possible_cpu(cpu)
 			kvfree(info->jumpstack[cpu]);
 		kvfree(info->jumpstack);
@@ -1401,7 +1401,7 @@ static void *xt_mttg_seq_next(struct seq_file *seq, void *v, loff_t *ppos,
 		return NULL;
 	}
 
-	if (ppos != NULL)
+	if (ppos)
 		++*ppos;
 	return trav;
 }
net/netfilter/xt_TCPMSS.c +2 -2
index 27241a767f17..6dac2c2e40ea 100644
@@ -64,11 +64,11 @@ static u_int32_t tcpmss_reverse_mtu(struct net *net,
 	}
 	rcu_read_lock();
 	ai = nf_get_afinfo(family);
-	if (ai != NULL)
+	if (ai)
 		ai->route(net, (struct dst_entry **)&rt, &fl, false);
 	rcu_read_unlock();
 
-	if (rt != NULL) {
+	if (rt) {
 		mtu = dst_mtu(&rt->dst);
 		dst_release(&rt->dst);
 	}
net/netfilter/xt_addrtype.c +1 -1
index e329dabde35f..836e9ba7d55b 100644
@@ -50,7 +50,7 @@ static u32 match_lookup_rt6(struct net *net, const struct net_device *dev,
 	rcu_read_lock();
 
 	afinfo = nf_get_afinfo(NFPROTO_IPV6);
-	if (afinfo != NULL) {
+	if (afinfo) {
 		const struct nf_ipv6_ops *v6ops;
 
 		if (dev && (mask & XT_ADDRTYPE_LOCAL)) {
net/netfilter/xt_connlimit.c +1 -1
index b8fd4ab762ed..5407e644a929 100644
@@ -328,7 +328,7 @@ connlimit_mt(const struct sk_buff *skb, struct xt_action_param *par)
 	unsigned int connections;
 
 	ct = nf_ct_get(skb, &ctinfo);
-	if (ct != NULL) {
+	if (ct) {
 		tuple_ptr = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
 		zone = nf_ct_zone(ct);
 	} else if (!nf_ct_get_tuplepr(skb, skb_network_offset(skb),
net/netfilter/xt_conntrack.c +1 -1
index c0fb217bc649..617815b57d71 100644
@@ -181,7 +181,7 @@ conntrack_mt(const struct sk_buff *skb, struct xt_action_param *par,
 		statebit = XT_CONNTRACK_STATE_INVALID;
 
 	if (info->match_flags & XT_CONNTRACK_STATE) {
-		if (ct != NULL) {
+		if (ct) {
 			if (test_bit(IPS_SRC_NAT_BIT, &ct->status))
 				statebit |= XT_CONNTRACK_STATE_SNAT;
 			if (test_bit(IPS_DST_NAT_BIT, &ct->status))
net/netfilter/xt_hashlimit.c +2 -2
index 2a6dfe8b74d3..244a4ac1ba58 100644
@@ -193,7 +193,7 @@ dsthash_alloc_init(struct xt_hashlimit_htable *ht,
 	 * hashtable, double check if this packet lost race.
 	 */
 	ent = dsthash_find(ht, dst);
-	if (ent != NULL) {
+	if (ent) {
 		spin_unlock(&ht->lock);
 		*race = true;
 		return ent;
@@ -368,7 +368,7 @@ static void htable_remove_proc_entry(struct xt_hashlimit_htable *hinfo)
 	else
 		parent = hashlimit_net->ip6t_hashlimit;
 
-	if (parent != NULL)
+	if (parent)
 		remove_proc_entry(hinfo->name, parent);
 }
 
net/netfilter/xt_recent.c +3 -3
index 1d89a4eaf841..47e7adaec00e 100644
@@ -374,7 +374,7 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
 
 	mutex_lock(&recent_mutex);
 	t = recent_table_lookup(recent_net, info->name);
-	if (t != NULL) {
+	if (t) {
 		if (nstamp_mask > t->nstamps_max_mask) {
 			spin_lock_bh(&recent_lock);
 			recent_table_flush(t);
@@ -461,7 +461,7 @@ static void recent_mt_destroy(const struct xt_mtdtor_param *par)
 		list_del(&t->list);
 		spin_unlock_bh(&recent_lock);
 #ifdef CONFIG_PROC_FS
-		if (recent_net->xt_recent != NULL)
+		if (recent_net->xt_recent)
 			remove_proc_entry(t->name, recent_net->xt_recent);
 #endif
 		recent_table_flush(t);
@@ -596,7 +596,7 @@ recent_mt_proc_write(struct file *file, const char __user *input,
 
 	++c;
 	--size;
-	if (strnchr(c, size, ':') != NULL) {
+	if (strnchr(c, size, ':')) {
 		family = NFPROTO_IPV6;
 		succ   = in6_pton(c, size, (void *)&addr, '\n', NULL);
 	} else {
Signature · 1 line
2.11.0