Re: [PATCH 10/10] firewire-net: Adjust checks for null pointers in five functions

2016-09-24 Thread Stefan Richter
On Sep 18 SF Markus Elfring wrote:
> The script "checkpatch.pl" can point information out like the following.

A side note:  checkpatch.pl is for authors to help prepare their
submissions of new code (or their refactoring of existing code if for some
reason a refactoring is undertaken).

> Comparison to NULL could be written !…

Yes it could, or it could remain as is.  Both styles are used in
drivers/firewire/net.c, so it is indeed preferable to normalize it to one
of them.  I keep your patch for the next occasion when related work is
being done on drivers/firewire/net.c or drivers/firewire.

> Thus fix the affected source code places.

It is not a "fix", it is a stylistic change.

> Signed-off-by: Markus Elfring 
> ---
>  drivers/firewire/net.c | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
> index eb7ce5e..e313be3 100644
> --- a/drivers/firewire/net.c
> +++ b/drivers/firewire/net.c
> @@ -366,13 +366,13 @@ static struct fwnet_partial_datagram 
> *fwnet_pd_new(struct net_device *net,
>  
>   INIT_LIST_HEAD(>fi_list);
>   fi = fwnet_frag_new(new, frag_off, frag_len);
> - if (fi == NULL)
> + if (!fi)
>   goto free_new;
[...]
-- 
Stefan Richter
-==- =--= ==---
http://arcgraph.de/sr/


Re: [PATCH 10/10] firewire-net: Adjust checks for null pointers in five functions

2016-09-24 Thread Stefan Richter
On Sep 18 SF Markus Elfring wrote:
> The script "checkpatch.pl" can point information out like the following.

A side note:  checkpatch.pl is for authors to help prepare their
submissions of new code (or their refactoring of existing code if for some
reason a refactoring is undertaken).

> Comparison to NULL could be written !…

Yes it could, or it could remain as is.  Both styles are used in
drivers/firewire/net.c, so it is indeed preferable to normalize it to one
of them.  I keep your patch for the next occasion when related work is
being done on drivers/firewire/net.c or drivers/firewire.

> Thus fix the affected source code places.

It is not a "fix", it is a stylistic change.

> Signed-off-by: Markus Elfring 
> ---
>  drivers/firewire/net.c | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
> index eb7ce5e..e313be3 100644
> --- a/drivers/firewire/net.c
> +++ b/drivers/firewire/net.c
> @@ -366,13 +366,13 @@ static struct fwnet_partial_datagram 
> *fwnet_pd_new(struct net_device *net,
>  
>   INIT_LIST_HEAD(>fi_list);
>   fi = fwnet_frag_new(new, frag_off, frag_len);
> - if (fi == NULL)
> + if (!fi)
>   goto free_new;
[...]
-- 
Stefan Richter
-==- =--= ==---
http://arcgraph.de/sr/


[PATCH 10/10] firewire-net: Adjust checks for null pointers in five functions

2016-09-18 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 18 Sep 2016 07:48:56 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" can point information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/firewire/net.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index eb7ce5e..e313be3 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -366,13 +366,13 @@ static struct fwnet_partial_datagram *fwnet_pd_new(struct 
net_device *net,
 
INIT_LIST_HEAD(>fi_list);
fi = fwnet_frag_new(new, frag_off, frag_len);
-   if (fi == NULL)
+   if (!fi)
goto free_new;
 
new->datagram_label = datagram_label;
new->datagram_size = dg_size;
new->skb = dev_alloc_skb(dg_size + LL_RESERVED_SPACE(net));
-   if (new->skb == NULL)
+   if (!new->skb)
goto free_fragment_info;
 
skb_reserve(new->skb, LL_RESERVED_SPACE(net));
@@ -418,7 +418,7 @@ static bool fwnet_pd_update(struct fwnet_peer *peer,
struct fwnet_partial_datagram *pd, void *frag_buf,
unsigned frag_off, unsigned frag_len)
 {
-   if (fwnet_frag_new(pd, frag_off, frag_len) == NULL)
+   if (!fwnet_frag_new(pd, frag_off, frag_len))
return false;
 
memcpy(pd->pbuf + frag_off, frag_buf, frag_len);
@@ -623,7 +623,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, 
__be32 *buf, int len,
}
 
pd = fwnet_pd_find(peer, datagram_label);
-   if (pd == NULL) {
+   if (!pd) {
while (peer->pdg_size >= FWNET_MAX_FRAGMENTS) {
/* remove the oldest */
fwnet_pd_delete(list_first_entry(>pd_list,
@@ -632,7 +632,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, 
__be32 *buf, int len,
}
pd = fwnet_pd_new(net, peer, datagram_label,
  dg_size, buf, fg_off, len);
-   if (pd == NULL) {
+   if (!pd) {
retval = -ENOMEM;
goto unlock;
}
@@ -647,7 +647,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, 
__be32 *buf, int len,
fwnet_pd_delete(pd);
pd = fwnet_pd_new(net, peer, datagram_label,
  dg_size, buf, fg_off, len);
-   if (pd == NULL) {
+   if (!pd) {
peer->pdg_size--;
retval = -ENOMEM;
goto unlock;
@@ -1229,7 +1229,7 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct 
net_device *net)
}
 
ptask = kmem_cache_alloc(fwnet_packet_task_cache, GFP_ATOMIC);
-   if (ptask == NULL)
+   if (!ptask)
goto unlock;
 
skb = skb_share_check(skb, GFP_ATOMIC);
@@ -1443,7 +1443,7 @@ static int fwnet_probe(struct fw_unit *unit,
 
net = alloc_netdev(sizeof(*dev), "firewire%d", NET_NAME_UNKNOWN,
   fwnet_init_dev);
-   if (net == NULL) {
+   if (!net) {
mutex_unlock(_device_mutex);
return -ENOMEM;
}
-- 
2.10.0



[PATCH 10/10] firewire-net: Adjust checks for null pointers in five functions

2016-09-18 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 18 Sep 2016 07:48:56 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" can point information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/firewire/net.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index eb7ce5e..e313be3 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -366,13 +366,13 @@ static struct fwnet_partial_datagram *fwnet_pd_new(struct 
net_device *net,
 
INIT_LIST_HEAD(>fi_list);
fi = fwnet_frag_new(new, frag_off, frag_len);
-   if (fi == NULL)
+   if (!fi)
goto free_new;
 
new->datagram_label = datagram_label;
new->datagram_size = dg_size;
new->skb = dev_alloc_skb(dg_size + LL_RESERVED_SPACE(net));
-   if (new->skb == NULL)
+   if (!new->skb)
goto free_fragment_info;
 
skb_reserve(new->skb, LL_RESERVED_SPACE(net));
@@ -418,7 +418,7 @@ static bool fwnet_pd_update(struct fwnet_peer *peer,
struct fwnet_partial_datagram *pd, void *frag_buf,
unsigned frag_off, unsigned frag_len)
 {
-   if (fwnet_frag_new(pd, frag_off, frag_len) == NULL)
+   if (!fwnet_frag_new(pd, frag_off, frag_len))
return false;
 
memcpy(pd->pbuf + frag_off, frag_buf, frag_len);
@@ -623,7 +623,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, 
__be32 *buf, int len,
}
 
pd = fwnet_pd_find(peer, datagram_label);
-   if (pd == NULL) {
+   if (!pd) {
while (peer->pdg_size >= FWNET_MAX_FRAGMENTS) {
/* remove the oldest */
fwnet_pd_delete(list_first_entry(>pd_list,
@@ -632,7 +632,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, 
__be32 *buf, int len,
}
pd = fwnet_pd_new(net, peer, datagram_label,
  dg_size, buf, fg_off, len);
-   if (pd == NULL) {
+   if (!pd) {
retval = -ENOMEM;
goto unlock;
}
@@ -647,7 +647,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, 
__be32 *buf, int len,
fwnet_pd_delete(pd);
pd = fwnet_pd_new(net, peer, datagram_label,
  dg_size, buf, fg_off, len);
-   if (pd == NULL) {
+   if (!pd) {
peer->pdg_size--;
retval = -ENOMEM;
goto unlock;
@@ -1229,7 +1229,7 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct 
net_device *net)
}
 
ptask = kmem_cache_alloc(fwnet_packet_task_cache, GFP_ATOMIC);
-   if (ptask == NULL)
+   if (!ptask)
goto unlock;
 
skb = skb_share_check(skb, GFP_ATOMIC);
@@ -1443,7 +1443,7 @@ static int fwnet_probe(struct fw_unit *unit,
 
net = alloc_netdev(sizeof(*dev), "firewire%d", NET_NAME_UNKNOWN,
   fwnet_init_dev);
-   if (net == NULL) {
+   if (!net) {
mutex_unlock(_device_mutex);
return -ENOMEM;
}
-- 
2.10.0