summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMurali Karicheri <m-karicheri2@ti.com>2019-04-05 13:31:28 -0400
committerDavid S. Miller <davem@davemloft.net>2019-04-06 21:32:21 -0400
commit05ca6e644dc9b733379009137ba4cc7afce2256d (patch)
tree9132726d5a25f4dbf393027bb1d0b7882b981f6e
parent0525fc069f03dfd871752eb7afc85075444c8b28 (diff)
net: hsr: fix NULL checks in the code
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 <m-karicheri2@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/hsr/hsr_device.c2
-rw-r--r--net/hsr/hsr_forward.c12
-rw-r--r--net/hsr/hsr_framereg.c2
-rw-r--r--net/hsr/hsr_main.c4
-rw-r--r--net/hsr/hsr_slave.c6
5 files changed, 13 insertions, 13 deletions
diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
index 567c890f08a5..245fc531d39f 100644
--- a/net/hsr/hsr_device.c
+++ b/net/hsr/hsr_device.c
@@ -258,7 +258,7 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
258 sizeof(struct hsr_sup_tag) + 258 sizeof(struct hsr_sup_tag) +
259 sizeof(struct hsr_sup_payload) + hlen + tlen); 259 sizeof(struct hsr_sup_payload) + hlen + tlen);
260 260
261 if (skb == NULL) 261 if (!skb)
262 return; 262 return;
263 263
264 skb_reserve(skb, hlen); 264 skb_reserve(skb, hlen);
diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
index fdc191015208..68ca775d3be8 100644
--- a/net/hsr/hsr_forward.c
+++ b/net/hsr/hsr_forward.c
@@ -97,7 +97,7 @@ static struct sk_buff *create_stripped_skb(struct sk_buff *skb_in,
97 skb_pull(skb_in, HSR_HLEN); 97 skb_pull(skb_in, HSR_HLEN);
98 skb = __pskb_copy(skb_in, skb_headroom(skb_in) - HSR_HLEN, GFP_ATOMIC); 98 skb = __pskb_copy(skb_in, skb_headroom(skb_in) - HSR_HLEN, GFP_ATOMIC);
99 skb_push(skb_in, HSR_HLEN); 99 skb_push(skb_in, HSR_HLEN);
100 if (skb == NULL) 100 if (!skb)
101 return NULL; 101 return NULL;
102 102
103 skb_reset_mac_header(skb); 103 skb_reset_mac_header(skb);
@@ -160,7 +160,7 @@ static struct sk_buff *create_tagged_skb(struct sk_buff *skb_o,
160 160
161 /* Create the new skb with enough headroom to fit the HSR tag */ 161 /* Create the new skb with enough headroom to fit the HSR tag */
162 skb = __pskb_copy(skb_o, skb_headroom(skb_o) + HSR_HLEN, GFP_ATOMIC); 162 skb = __pskb_copy(skb_o, skb_headroom(skb_o) + HSR_HLEN, GFP_ATOMIC);
163 if (skb == NULL) 163 if (!skb)
164 return NULL; 164 return NULL;
165 skb_reset_mac_header(skb); 165 skb_reset_mac_header(skb);
166 166
@@ -277,7 +277,7 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
277 skb = frame_get_tagged_skb(frame, port); 277 skb = frame_get_tagged_skb(frame, port);
278 else 278 else
279 skb = frame_get_stripped_skb(frame, port); 279 skb = frame_get_stripped_skb(frame, port);
280 if (skb == NULL) { 280 if (!skb) {
281 /* FIXME: Record the dropped frame? */ 281 /* FIXME: Record the dropped frame? */
282 continue; 282 continue;
283 } 283 }
@@ -317,7 +317,7 @@ static int hsr_fill_frame_info(struct hsr_frame_info *frame,
317 317
318 frame->is_supervision = is_supervision_frame(port->hsr, skb); 318 frame->is_supervision = is_supervision_frame(port->hsr, skb);
319 frame->node_src = hsr_get_node(port, skb, frame->is_supervision); 319 frame->node_src = hsr_get_node(port, skb, frame->is_supervision);
320 if (frame->node_src == NULL) 320 if (!frame->node_src)
321 return -1; /* Unknown node and !is_supervision, or no mem */ 321 return -1; /* Unknown node and !is_supervision, or no mem */
322 322
323 ethhdr = (struct ethhdr *) skb_mac_header(skb); 323 ethhdr = (struct ethhdr *) skb_mac_header(skb);
@@ -364,9 +364,9 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port)
364 hsr_register_frame_in(frame.node_src, port, frame.sequence_nr); 364 hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
365 hsr_forward_do(&frame); 365 hsr_forward_do(&frame);
366 366
367 if (frame.skb_hsr != NULL) 367 if (frame.skb_hsr)
368 kfree_skb(frame.skb_hsr); 368 kfree_skb(frame.skb_hsr);
369 if (frame.skb_std != NULL) 369 if (frame.skb_std)
370 kfree_skb(frame.skb_std); 370 kfree_skb(frame.skb_std);
371 return; 371 return;
372 372
diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
index 78fca38ffa9f..c1b0e62af0f1 100644
--- a/net/hsr/hsr_framereg.c
+++ b/net/hsr/hsr_framereg.c
@@ -405,7 +405,7 @@ void hsr_prune_nodes(struct timer_list *t)
405 msecs_to_jiffies(1.5*MAX_SLAVE_DIFF))) { 405 msecs_to_jiffies(1.5*MAX_SLAVE_DIFF))) {
406 rcu_read_lock(); 406 rcu_read_lock();
407 port = get_late_port(hsr, node); 407 port = get_late_port(hsr, node);
408 if (port != NULL) 408 if (port)
409 hsr_nl_ringerror(hsr, node->MacAddressA, port); 409 hsr_nl_ringerror(hsr, node->MacAddressA, port);
410 rcu_read_unlock(); 410 rcu_read_unlock();
411 } 411 }
diff --git a/net/hsr/hsr_main.c b/net/hsr/hsr_main.c
index 0d4ab8fc0aa1..84cacf8c1b0a 100644
--- a/net/hsr/hsr_main.c
+++ b/net/hsr/hsr_main.c
@@ -30,12 +30,12 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
30 30
31 dev = netdev_notifier_info_to_dev(ptr); 31 dev = netdev_notifier_info_to_dev(ptr);
32 port = hsr_port_get_rtnl(dev); 32 port = hsr_port_get_rtnl(dev);
33 if (port == NULL) { 33 if (!port) {
34 if (!is_hsr_master(dev)) 34 if (!is_hsr_master(dev))
35 return NOTIFY_DONE; /* Not an HSR device */ 35 return NOTIFY_DONE; /* Not an HSR device */
36 hsr = netdev_priv(dev); 36 hsr = netdev_priv(dev);
37 port = hsr_port_get_hsr(hsr, HSR_PT_MASTER); 37 port = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
38 if (port == NULL) { 38 if (!port) {
39 /* Resend of notification concerning removed device? */ 39 /* Resend of notification concerning removed device? */
40 return NOTIFY_DONE; 40 return NOTIFY_DONE;
41 } 41 }
diff --git a/net/hsr/hsr_slave.c b/net/hsr/hsr_slave.c
index d506c694ee25..07cbc2ead64d 100644
--- a/net/hsr/hsr_slave.c
+++ b/net/hsr/hsr_slave.c
@@ -140,11 +140,11 @@ int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev,
140 } 140 }
141 141
142 port = hsr_port_get_hsr(hsr, type); 142 port = hsr_port_get_hsr(hsr, type);
143 if (port != NULL) 143 if (port)
144 return -EBUSY; /* This port already exists */ 144 return -EBUSY; /* This port already exists */
145 145
146 port = kzalloc(sizeof(*port), GFP_KERNEL); 146 port = kzalloc(sizeof(*port), GFP_KERNEL);
147 if (port == NULL) 147 if (!port)
148 return -ENOMEM; 148 return -ENOMEM;
149 149
150 if (type != HSR_PT_MASTER) { 150 if (type != HSR_PT_MASTER) {
@@ -181,7 +181,7 @@ void hsr_del_port(struct hsr_port *port)
181 list_del_rcu(&port->port_list); 181 list_del_rcu(&port->port_list);
182 182
183 if (port != master) { 183 if (port != master) {
184 if (master != NULL) { 184 if (master) {
185 netdev_update_features(master->dev); 185 netdev_update_features(master->dev);
186 dev_set_mtu(master->dev, hsr_get_max_mtu(hsr)); 186 dev_set_mtu(master->dev, hsr_get_max_mtu(hsr));
187 } 187 }