Skip to contentSkip to conversation

Staging: gdm724x: Remove print statement on failure

PATCH In review Bhumika Goyal 2 participants 3 messages Feb 28, 2016 1 message not in the archive Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: gdm724x: Remove print statement on failure

The memory allocation functions generates a call stack containing all the context information on failure, so print statements can be removed on failure of these functions.
Done using coccinelle:

@@
expression e;
@@

e=\(kmalloc\|kmalloc\|kmalloc_array\|alloc_netdev\|kzalloc\|
devm_kzalloc\|devm_ioremap\)(...);
...
if(!e){
- \(DBG_8723A\|printk\|pr_err\|CERROR\|DBG_88E\)(...); ...when any
}

---
 drivers/staging/gdm724x/gdm_lte.c | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/gdm724x/gdm_lte.c +0 -1
index 98570c6..44163e4 100644
@@ -890,7 +890,6 @@ int register_lte_device(struct phy_dev *phy_dev,
 		net = alloc_netdev(sizeof(struct nic), pdn_dev_name,
 				   NET_NAME_UNKNOWN, ether_setup);
 		if (!net) {
-			pr_err("alloc_netdev failed\n");
 			ret = -ENOMEM;
 			goto err;
 		}
Signature · 1 line
1.9.1
#1 lore raw
Quoted 27 lines · Bhumika Goyal

The memory allocation functions generates a call stack containing all the context information on failure, so print statements can be removed on failure of these functions.
Done using coccinelle:

@@
expression e;
@@

e=\(kmalloc\|kmalloc\|kmalloc_array\|alloc_netdev\|kzalloc\|
devm_kzalloc\|devm_ioremap\)(...);
...
if(!e){
- \(DBG_8723A\|printk\|pr_err\|CERROR\|DBG_88E\)(...); ...when any
}

---
 drivers/staging/gdm724x/gdm_lte.c | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/gdm724x/gdm_lte.c +0 -0
index 98570c6..44163e4 100644

drivers/staging/gdm724x/gdm_lte.c int register_lte_device(struct phy_dev *phy_dev, · line 893

Quoted 4 lines
drivers/staging/gdm724x/gdm_lte.c +0 -1
@@ -890,7 +890,6 @@ int register_lte_device(struct phy_dev *phy_dev,
 		net = alloc_netdev(sizeof(struct nic), pdn_dev_name,
 				   NET_NAME_UNKNOWN, ether_setup);
 		if (!net) {
-			pr_err("alloc_netdev failed\n");

Actually, if you unfold the definition a bit, alloc_netdev can fail for reasons other than kmalloc failure. So alloc_netdev should not be in the list. Likewise for (devm_)ioremap. It's not for all allocation functions where the message is superfluous, but only those based on kmalloc.

julia

Quoted 13 lines
drivers/staging/gdm724x/gdm_lte.c +0 -0
 			ret = -ENOMEM;
 			goto err;
 		}
Signature · 8 lines
1.9.1

-- 
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1456680767-435-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
#3 lore raw

PATCH 1/1 Staging: gdm724x: Remove print statement on failure

In reply to a message not in the archive
Quoted 39 lines · Julia Lawall
Quoted 27 lines · Bhumika Goyal

The memory allocation functions generates a call stack containing all the context information on failure, so print statements can be removed on failure of these functions.
Done using coccinelle:

@@
expression e;
@@

e=\(kmalloc\|kmalloc\|kmalloc_array\|alloc_netdev\|kzalloc\|
devm_kzalloc\|devm_ioremap\)(...);
...
if(!e){
- \(DBG_8723A\|printk\|pr_err\|CERROR\|DBG_88E\)(...); ...when any
}

---
 drivers/staging/gdm724x/gdm_lte.c | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/gdm724x/gdm_lte.c +0 -0
index 98570c6..44163e4 100644

drivers/staging/gdm724x/gdm_lte.c int register_lte_device(struct phy_dev *phy_dev, · line 893

Quoted 4 lines
drivers/staging/gdm724x/gdm_lte.c +0 -1
@@ -890,7 +890,6 @@ int register_lte_device(struct phy_dev *phy_dev,
              net = alloc_netdev(sizeof(struct nic), pdn_dev_name,
                                 NET_NAME_UNKNOWN, ether_setup);
              if (!net) {
-                     pr_err("alloc_netdev failed\n");

Actually, if you unfold the definition a bit, alloc_netdev can fail for reasons other than kmalloc failure. So alloc_netdev should not be in the list. Likewise for (devm_)ioremap. It's not for all allocation functions where the message is superfluous, but only those based on kmalloc.

Quoted 2 lines

julia

Ok I got the point and I will keep the patch limited to only kmalloc based functions. I will drop this patch.

Thanks,
Bhumika

Quoted 13 lines
Quoted 13 lines
drivers/staging/gdm724x/gdm_lte.c +0 -1
                      ret = -ENOMEM;
                      goto err;
              }
--

1.9.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1456680767-435-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.