Skip to content

Commit

Permalink
net: hsr: fix NULL checks in the code
Browse files Browse the repository at this point in the history
This patch replaces all instance of NULL checks such as
    if (foo == NULL) with if (!foo)
Also
    if (foo != NULL) with if (foo)

This is seen when ran checkpatch.pl -f on files under net/hsr
and suggestion is to replace as above.

Signed-off-by: Murali Karicheri <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Murali Karicheri authored and davem330 committed Apr 7, 2019
1 parent 0525fc0 commit 05ca6e6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion net/hsr/hsr_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
sizeof(struct hsr_sup_tag) +
sizeof(struct hsr_sup_payload) + hlen + tlen);

if (skb == NULL)
if (!skb)
return;

skb_reserve(skb, hlen);
Expand Down
12 changes: 6 additions & 6 deletions net/hsr/hsr_forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static struct sk_buff *create_stripped_skb(struct sk_buff *skb_in,
skb_pull(skb_in, HSR_HLEN);
skb = __pskb_copy(skb_in, skb_headroom(skb_in) - HSR_HLEN, GFP_ATOMIC);
skb_push(skb_in, HSR_HLEN);
if (skb == NULL)
if (!skb)
return NULL;

skb_reset_mac_header(skb);
Expand Down Expand Up @@ -160,7 +160,7 @@ static struct sk_buff *create_tagged_skb(struct sk_buff *skb_o,

/* Create the new skb with enough headroom to fit the HSR tag */
skb = __pskb_copy(skb_o, skb_headroom(skb_o) + HSR_HLEN, GFP_ATOMIC);
if (skb == NULL)
if (!skb)
return NULL;
skb_reset_mac_header(skb);

Expand Down Expand Up @@ -277,7 +277,7 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
skb = frame_get_tagged_skb(frame, port);
else
skb = frame_get_stripped_skb(frame, port);
if (skb == NULL) {
if (!skb) {
/* FIXME: Record the dropped frame? */
continue;
}
Expand Down Expand Up @@ -317,7 +317,7 @@ static int hsr_fill_frame_info(struct hsr_frame_info *frame,

frame->is_supervision = is_supervision_frame(port->hsr, skb);
frame->node_src = hsr_get_node(port, skb, frame->is_supervision);
if (frame->node_src == NULL)
if (!frame->node_src)
return -1; /* Unknown node and !is_supervision, or no mem */

ethhdr = (struct ethhdr *) skb_mac_header(skb);
Expand Down Expand Up @@ -364,9 +364,9 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port)
hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
hsr_forward_do(&frame);

if (frame.skb_hsr != NULL)
if (frame.skb_hsr)
kfree_skb(frame.skb_hsr);
if (frame.skb_std != NULL)
if (frame.skb_std)
kfree_skb(frame.skb_std);
return;

Expand Down
2 changes: 1 addition & 1 deletion net/hsr/hsr_framereg.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ void hsr_prune_nodes(struct timer_list *t)
msecs_to_jiffies(1.5*MAX_SLAVE_DIFF))) {
rcu_read_lock();
port = get_late_port(hsr, node);
if (port != NULL)
if (port)
hsr_nl_ringerror(hsr, node->MacAddressA, port);
rcu_read_unlock();
}
Expand Down
4 changes: 2 additions & 2 deletions net/hsr/hsr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,

dev = netdev_notifier_info_to_dev(ptr);
port = hsr_port_get_rtnl(dev);
if (port == NULL) {
if (!port) {
if (!is_hsr_master(dev))
return NOTIFY_DONE; /* Not an HSR device */
hsr = netdev_priv(dev);
port = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
if (port == NULL) {
if (!port) {
/* Resend of notification concerning removed device? */
return NOTIFY_DONE;
}
Expand Down
6 changes: 3 additions & 3 deletions net/hsr/hsr_slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev,
}

port = hsr_port_get_hsr(hsr, type);
if (port != NULL)
if (port)
return -EBUSY; /* This port already exists */

port = kzalloc(sizeof(*port), GFP_KERNEL);
if (port == NULL)
if (!port)
return -ENOMEM;

if (type != HSR_PT_MASTER) {
Expand Down Expand Up @@ -181,7 +181,7 @@ void hsr_del_port(struct hsr_port *port)
list_del_rcu(&port->port_list);

if (port != master) {
if (master != NULL) {
if (master) {
netdev_update_features(master->dev);
dev_set_mtu(master->dev, hsr_get_max_mtu(hsr));
}
Expand Down

0 comments on commit 05ca6e6

Please sign in to comment.