net: bridge: netfilter: Comparison to NULL could be written
Subsystems (4)
PATCH 1/1 net: bridge: netfilter: Comparison to NULL could be written
Fixed coding style for null comparisons to be more consistant with the rest of the kernel coding style.
Signed-off-by Arushi Singhal <[email protected]>
--- net/bridge/netfilter/ebt_among.c | 12 ++++++------ net/bridge/netfilter/ebt_arp.c | 10 +++++----- net/bridge/netfilter/ebt_arpreply.c | 8 ++++---- net/bridge/netfilter/ebt_ip.c | 4 ++-- net/bridge/netfilter/ebt_ip6.c | 4 ++-- net/bridge/netfilter/ebt_log.c | 10 +++++----- net/bridge/netfilter/ebt_snat.c | 2 +- net/bridge/netfilter/ebt_stp.c | 4 ++-- net/bridge/netfilter/ebt_vlan.c | 2 +- net/bridge/netfilter/ebtables.c | 18 ++++++++++-------- net/bridge/netfilter/nf_tables_bridge.c | 2 +- net/bridge/netfilter/nft_meta_bridge.c | 6 +++--- net/bridge/netfilter/nft_reject_bridge.c | 4 ++-- 13 files changed, 44 insertions(+), 42 deletions(-)
net/bridge/netfilter/ebt_among.c +6 -6
@@ -74,7 +74,7 @@ static int get_ip_dst(const struct sk_buff *skb, __be32 *addr)struct iphdr _iph; ih =skb_header_pointer (skb,0 ,sizeof (_iph), &_iph); -if (ih ==NULL ) +if (!ih)return -1 ; *addr = ih->daddr; }else if (eth_hdr (skb)->h_proto ==htons (ETH_P_ARP )) {
@@ -84,14 +84,14 @@ static int get_ip_dst(const struct sk_buff *skb, __be32 *addr)__be32 buf; ah =skb_header_pointer (skb,0 ,sizeof (_arph), &_arph); -if (ah ==NULL || +if (!ah || ah->ar_pln !=sizeof (__be32) || ah->ar_hln !=ETH_ALEN )return -1 ; bp =skb_header_pointer (skb,sizeof (struct arphdr ) +2 *ETH_ALEN +sizeof (__be32),sizeof (__be32), &buf); -if (bp ==NULL ) +if (!bp)return -1 ; *addr = *bp; }
@@ -105,7 +105,7 @@ static int get_ip_src(const struct sk_buff *skb, __be32 *addr)struct iphdr _iph; ih =skb_header_pointer (skb,0 ,sizeof (_iph), &_iph); -if (ih ==NULL ) +if (!ih)return -1 ; *addr = ih->saddr; }else if (eth_hdr (skb)->h_proto ==htons (ETH_P_ARP )) {
@@ -115,13 +115,13 @@ static int get_ip_src(const struct sk_buff *skb, __be32 *addr)__be32 buf; ah =skb_header_pointer (skb,0 ,sizeof (_arph), &_arph); -if (ah ==NULL || +if (!ah || ah->ar_pln !=sizeof (__be32) || ah->ar_hln !=ETH_ALEN )return -1 ; bp =skb_header_pointer (skb,sizeof (struct arphdr ) +ETH_ALEN ,sizeof (__be32), &buf); -if (bp ==NULL ) +if (!bp)return -1 ; *addr = *bp; }
net/bridge/netfilter/ebt_arp.c +5 -5
@@ -23,7 +23,7 @@ ebt_arp_mt(const struct sk_buff *skb, struct xt_action_param *par)struct arphdr _arph; ah =skb_header_pointer (skb,0 ,sizeof (_arph), &_arph); -if (ah ==NULL ) +if (!ah)return false;if ((info->bitmask &EBT_ARP_OPCODE ) &&NF_INVF (info,EBT_ARP_OPCODE , info->opcode != ah->ar_op))
@@ -44,12 +44,12 @@ ebt_arp_mt(const struct sk_buff *skb, struct xt_action_param *par) sap =skb_header_pointer (skb,sizeof (struct arphdr ) + ah->ar_hln,sizeof (saddr), &saddr); -if (sap ==NULL ) +if (!sap)return false; dap =skb_header_pointer (skb,sizeof (struct arphdr ) +2 *ah->ar_hln+sizeof (saddr),sizeof (daddr), &daddr); -if (dap ==NULL ) +if (!dap)return false;if ((info->bitmask &EBT_ARP_SRC_IP ) && NF_INVF(info, EBT_ARP_SRC_IP,
@@ -73,7 +73,7 @@ ebt_arp_mt(const struct sk_buff *skb, struct xt_action_param *par) if (info->bitmask & EBT_ARP_SRC_MAC) { mp = skb_header_pointer(skb, sizeof(struct arphdr), sizeof(_mac), &_mac); - if (mp == NULL) + if (!mp) return false; if (NF_INVF(info, EBT_ARP_SRC_MAC, !ether_addr_equal_masked(mp, info->smaddr,
@@ -85,7 +85,7 @@ ebt_arp_mt(const struct sk_buff *skb, struct xt_action_param *par) mp =skb_header_pointer (skb,sizeof (struct arphdr ) + ah->ar_hln + ah->ar_pln,sizeof (_mac), &_mac); -if (mp ==NULL ) +if (!mp)return false; if (NF_INVF(info, EBT_ARP_DST_MAC, !ether_addr_equal_masked(mp, info->dmaddr,
net/bridge/netfilter/ebt_arpreply.c +4 -4
@@ -27,7 +27,7 @@ ebt_arpreply_tg(struct sk_buff *skb, const struct xt_action_param *par)unsigned char _sha[ETH_ALEN ]; ap =skb_header_pointer (skb,0 ,sizeof (_ah), &_ah); -if (ap ==NULL ) +if (!ap)return EBT_DROP ; if (ap->ar_op != htons(ARPOP_REQUEST) ||
@@ -37,18 +37,18 @@ ebt_arpreply_tg(struct sk_buff *skb, const struct xt_action_param *par)return EBT_CONTINUE ; shp =skb_header_pointer (skb,sizeof (_ah),ETH_ALEN , &_sha); -if (shp ==NULL ) +if (!shp)return EBT_DROP ; siptr =skb_header_pointer (skb,sizeof (_ah) +ETH_ALEN ,sizeof (_sip), &_sip); -if (siptr ==NULL ) +if (!siptr)return EBT_DROP ; diptr =skb_header_pointer (skb,sizeof (_ah) +2 *ETH_ALEN +sizeof (_sip),sizeof (_dip), &_dip); -if (diptr ==NULL ) +if (!diptr)return EBT_DROP ; arp_send(ARPOP_REPLY, ETH_P_ARP, *siptr,
net/bridge/netfilter/ebt_ip.c +2 -2
@@ -34,7 +34,7 @@ ebt_ip_mt(const struct sk_buff *skb, struct xt_action_param *par)struct tcpudphdr _ports; ih =skb_header_pointer (skb,0 ,sizeof (_iph), &_iph); -if (ih ==NULL ) +if (!ih)return false;if ((info->bitmask &EBT_IP_TOS ) &&NF_INVF (info,EBT_IP_TOS , info->tos != ih->tos))
@@ -57,7 +57,7 @@ ebt_ip_mt(const struct sk_buff *skb, struct xt_action_param *par)return false; pptr =skb_header_pointer (skb, ih->ihl*4 ,sizeof (_ports), &_ports); -if (pptr ==NULL ) +if (!pptr)return false;if (info->bitmask &EBT_IP_DPORT ) {u32 dst =ntohs (pptr->dst);
net/bridge/netfilter/ebt_ip6.c +2 -2
@@ -43,7 +43,7 @@ ebt_ip6_mt(const struct sk_buff *skb, struct xt_action_param *par)union pkthdr _pkthdr; ih6 =skb_header_pointer (skb,0 ,sizeof (_ip6h), &_ip6h); -if (ih6 ==NULL ) +if (!ih6)return false;if ((info->bitmask &EBT_IP6_TCLASS ) && NF_INVF(info, EBT_IP6_TCLASS,
@@ -75,7 +75,7 @@ ebt_ip6_mt(const struct sk_buff *skb, struct xt_action_param *par)/* min icmpv6 headersize is 4, so sizeof(_pkthdr) is ok. */ pptr =skb_header_pointer (skb, offset_ph,sizeof (_pkthdr), &_pkthdr); -if (pptr ==NULL ) +if (!pptr)return false;if (info->bitmask &EBT_IP6_DPORT ) {u16 dst =ntohs (pptr->tcpudphdr.dst);
net/bridge/netfilter/ebt_log.c +5 -5
@@ -61,7 +61,7 @@ print_ports(const struct sk_buff *skb, uint8_t protocol, int offset) pptr =skb_header_pointer (skb, offset,sizeof (_ports), &_ports); -if (pptr ==NULL ) { +if (!pptr) {printk (" INCOMPLETE TCP/UDP header" );return ; }
@@ -99,7 +99,7 @@ ebt_log_packet(struct net *net, u_int8_t pf, unsigned int hooknum,struct iphdr _iph; ih =skb_header_pointer (skb,0 ,sizeof (_iph), &_iph); -if (ih ==NULL ) { +if (!ih) {printk (" INCOMPLETE IP header" ); goto out; }
@@ -119,7 +119,7 @@ ebt_log_packet(struct net *net, u_int8_t pf, unsigned int hooknum,int offset_ph; ih =skb_header_pointer (skb,0 ,sizeof (_iph), &_iph); -if (ih ==NULL ) { +if (!ih) {printk (" INCOMPLETE IPv6 header" ); goto out; }
@@ -141,7 +141,7 @@ ebt_log_packet(struct net *net, u_int8_t pf, unsigned int hooknum,struct arphdr _arph; ah =skb_header_pointer (skb,0 ,sizeof (_arph), &_arph); -if (ah ==NULL ) { +if (!ah) {printk (" INCOMPLETE ARP header" ); goto out; }
@@ -160,7 +160,7 @@ ebt_log_packet(struct net *net, u_int8_t pf, unsigned int hooknum, ap =skb_header_pointer (skb,sizeof (_arph),sizeof (_arpp), &_arpp); -if (ap ==NULL ) { +if (!ap) {printk (" INCOMPLETE ARP payload" ); goto out; }
net/bridge/netfilter/ebt_snat.c +1 -1
@@ -31,7 +31,7 @@ ebt_snat_tg(struct sk_buff *skb, const struct xt_action_param *par)struct arphdr _ah; ap =skb_header_pointer (skb,0 ,sizeof (_ah), &_ah); -if (ap ==NULL ) +if (!ap)return EBT_DROP ;if (ap->ar_hln !=ETH_ALEN ) goto out;
net/bridge/netfilter/ebt_stp.c +2 -2
@@ -125,7 +125,7 @@ ebt_stp_mt(const struct sk_buff *skb, struct xt_action_param *par)const u8 header[6 ] = {0x42 ,0x42 ,0x03 ,0x00 ,0x00 ,0x00 }; sp =skb_header_pointer (skb,0 ,sizeof (_stph), &_stph); -if (sp ==NULL ) +if (!sp)return false;/* The stp code only considers these */
@@ -143,7 +143,7 @@ ebt_stp_mt(const struct sk_buff *skb, struct xt_action_param *par) st =skb_header_pointer (skb,sizeof (_stph),sizeof (_stpc), &_stpc); -if (st ==NULL ) +if (!st)return false;return ebt_filter_config (info, st); }
net/bridge/netfilter/ebt_vlan.c +1 -1
@@ -53,7 +53,7 @@ ebt_vlan_mt(const struct sk_buff *skb, struct xt_action_param *par)struct vlan_hdr _frame; fp =skb_header_pointer (skb,0 ,sizeof (_frame), &_frame); -if (fp ==NULL ) +if (!fp)return false;TCI =ntohs (fp->h_vlan_TCI);
net/bridge/netfilter/ebtables.c +10 -8
@@ -596,7 +596,7 @@ ebt_cleanup_match(struct ebt_entry_match *m, struct net *net, unsigned int *i) par.match = m->u.match; par.matchinfo = m->data; par.family =NFPROTO_BRIDGE ; -if (par.match->destroy !=NULL ) +if (par.match->destroy) par.match->destroy (&par);module_put (par.match->me);return 0 ;
@@ -614,7 +614,7 @@ ebt_cleanup_watcher(struct ebt_entry_watcher *w, struct net *net, unsigned int * par.target = w->u.watcher; par.targinfo = w->data; par.family =NFPROTO_BRIDGE ; -if (par.target->destroy !=NULL ) +if (par.target->destroy) par.target->destroy (&par);module_put (par.target->me);return 0 ;
@@ -639,7 +639,7 @@ ebt_cleanup_entry(struct ebt_entry *e, struct net *net, unsigned int *cnt) par.target = t->u.target; par.targinfo = t->data; par.family =NFPROTO_BRIDGE ; -if (par.target->destroy !=NULL ) +if (par.target->destroy) par.target->destroy (&par);module_put (par.target->me);return 0 ;
@@ -1166,9 +1166,11 @@ ebt_register_table(struct net *net, const struct ebt_table *input_table)int ret, i, countersize;void *p; -if (input_table ==NULL || (repl = input_table->table) ==NULL || - repl->entries ==NULL || repl->entries_size ==0 || - repl->counters !=NULL || input_table->private !=NULL ) { + repl = input_table->table; + +if (!input_table || !repl || !repl->entries || + repl->entries_size ==0 || repl->counters || + input_table->private) {BUGPRINT ("Bad table data for ebt_register_table!!!\n" );return ERR_PTR (-EINVAL ); }
@@ -1889,7 +1891,7 @@ static int ebt_buf_count(struct ebt_entries_buf_state *state, unsigned int sz)static int ebt_buf_add (struct ebt_entries_buf_state *state,void *data,unsigned int sz) { -if (state->buf_kern_start ==NULL ) +if (!state->buf_kern_start) goto count_only;BUG_ON (state->buf_kern_offset + sz > state->buf_kern_len);
@@ -2121,7 +2123,7 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base, } } -if (state->buf_kern_start ==NULL ) { +if (!state->buf_kern_start) {unsigned int offset = buf_start - (char *) base; ret =xt_compat_add_offset (NFPROTO_BRIDGE , offset, new_offset);
net/bridge/netfilter/nf_tables_bridge.c +1 -1
@@ -57,7 +57,7 @@ static struct nft_af_info nft_af_bridge __read_mostly = {static int nf_tables_bridge_init_net (struct net *net) { net->nft.bridge =kmalloc (sizeof (struct nft_af_info ),GFP_KERNEL ); -if (net->nft.bridge ==NULL ) +if (!net->nft.bridge)return -ENOMEM ;memcpy (net->nft.bridge, &nft_af_bridge,sizeof (nft_af_bridge));
net/bridge/netfilter/nft_meta_bridge.c +3 -3
@@ -29,11 +29,11 @@ static void nft_meta_bridge_get_eval(const struct nft_expr *expr,switch (priv->key) {case NFT_META_BRI_IIFNAME : -if (in ==NULL || (p =br_port_get_rcu (in)) ==NULL ) +if (!in || !(p =br_port_get_rcu (in))) goto err;break ;case NFT_META_BRI_OIFNAME : -if (out ==NULL || (p =br_port_get_rcu (out)) ==NULL ) +if (!out || !(p =br_port_get_rcu (out))) goto err;break ;default :
@@ -93,7 +93,7 @@ static const struct nft_expr_ops * nft_meta_bridge_select_ops(const struct nft_ctx *ctx, const struct nlattr * const tb[]) { - if (tb[NFTA_META_KEY] == NULL) +if (!tb[NFTA_META_KEY ])return ERR_PTR (-EINVAL );if (tb[NFTA_META_DREG ] && tb[NFTA_META_SREG ])
net/bridge/netfilter/nft_reject_bridge.c +2 -2
@@ -381,14 +381,14 @@ static int nft_reject_bridge_init(const struct nft_ctx *ctx,if (err <0 )return err; -if (tb[NFTA_REJECT_TYPE ] ==NULL ) +if (!tb[NFTA_REJECT_TYPE ])return -EINVAL ; priv->type =ntohl (nla_get_be32 (tb[NFTA_REJECT_TYPE ]));switch (priv->type) {case NFT_REJECT_ICMP_UNREACH :case NFT_REJECT_ICMPX_UNREACH : -if (tb[NFTA_REJECT_ICMP_CODE ] ==NULL ) +if (!tb[NFTA_REJECT_ICMP_CODE ])return -EINVAL ; icmp_code =nla_get_u8 (tb[NFTA_REJECT_ICMP_CODE ]);
Signature · 1 line
2.11.0