Skip to contentSkip to conversation

Staging: rtl8723au: Remove print statements and debug messages

PATCH Superseded Bhumika Goyal 2 participants 2 messages Feb 28, 2016 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: rtl8723au: Remove print statements and debug messages

The memory allocation functions generates a call stack containing all the context information on failure, so print statements and debug messages can be removed on failure of these functions. Also remove unwanted {} around if block after removal of these messages. 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/rtl8723au/hal/usb_ops_linux.c     | 6 +-----
 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 3 ---
 2 files changed, 1 insertion(+), 8 deletions(-)
drivers/staging/rtl8723au/hal/usb_ops_linux.c +1 -5
index 371e6b3..5c81ff4 100644
@@ -256,12 +256,8 @@ static void usb_read_interrupt_complete(struct urb *purb)
 				c2w = kmalloc(sizeof(struct evt_work),
 						GFP_ATOMIC);
 
-				if (!c2w) {
-					printk(KERN_WARNING "%s: unable to "
-					       "allocate work buffer\n",
-					       __func__);
+				if (!c2w)
 					goto urb_submit;
-				}
 
 				c2w->adapter = padapter;
 				INIT_WORK(&c2w->work, rtw_evt_work);
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +0 -3
index cf0daa1..722d5f5 100644
@@ -2608,8 +2608,6 @@ static int rtw_cfg80211_add_monitor_if(struct rtw_adapter *padapter, char *name,
 	/*  wdev */
 	mon_wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
 	if (!mon_wdev) {
-		DBG_8723A("%s(%s): allocate mon_wdev fail\n", __func__,
-			  padapter->pnetdev->name);
 		ret = -ENOMEM;
 		goto out;
 	}
@@ -3260,7 +3258,6 @@ int rtw_wdev_alloc(struct rtw_adapter *padapter, struct device *dev)
 	/*  wdev */
 	wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
 	if (!wdev) {
-		DBG_8723A("Couldn't allocate wireless device\n");
 		ret = -ENOMEM;
 		goto free_wiphy;
 	}
Signature · 1 line
1.9.1
#1 lore raw
Quoted 6 lines · Bhumika Goyal

The memory allocation functions generates a call stack containing all the context information on failure, so print statements and debug messages can be removed on failure of these functions. Also remove unwanted {} around if block after removal of these messages. Done using coccinelle:

Quoted 7 lines

@@
expression e;
@@

e=\(kmalloc\|kmalloc\|kmalloc_array\|alloc_netdev\|kzalloc\|
devm_kzalloc\|devm_ioremap\)(...);
...

The semantic patch would be a little nicer with

... when != e = e1

here, to indicate that e has not been redefined. Otherwise, if there is actually no null test for this specific call, and the variable is defined later, you could end up removing a debug message for something else.

Quoted 4 lines

if(!e){
- \(DBG_8723A\|printk\|pr_err\|CERROR\|DBG_88E\)(...); ...when any
}

This is a bit restrictive in that it requires the debug message to come first. It could be reasonable to put a ... before the print statement. If you put ... without any when annotation, it will ensure that there is no earlier print statement, and you will be dropping the first one, which is probably what you want.

julia

Quoted 56 lines
---
 drivers/staging/rtl8723au/hal/usb_ops_linux.c     | 6 +-----
 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 3 ---
 2 files changed, 1 insertion(+), 8 deletions(-)
drivers/staging/rtl8723au/hal/usb_ops_linux.c +1 -5
index 371e6b3..5c81ff4 100644
@@ -256,12 +256,8 @@ static void usb_read_interrupt_complete(struct urb *purb)
 				c2w = kmalloc(sizeof(struct evt_work),
 						GFP_ATOMIC);
 
-				if (!c2w) {
-					printk(KERN_WARNING "%s: unable to "
-					       "allocate work buffer\n",
-					       __func__);
+				if (!c2w)
 					goto urb_submit;
-				}
 
 				c2w->adapter = padapter;
 				INIT_WORK(&c2w->work, rtw_evt_work);
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +0 -3
index cf0daa1..722d5f5 100644
@@ -2608,8 +2608,6 @@ static int rtw_cfg80211_add_monitor_if(struct rtw_adapter *padapter, char *name,
 	/*  wdev */
 	mon_wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
 	if (!mon_wdev) {
-		DBG_8723A("%s(%s): allocate mon_wdev fail\n", __func__,
-			  padapter->pnetdev->name);
 		ret = -ENOMEM;
 		goto out;
 	}
@@ -3260,7 +3258,6 @@ int rtw_wdev_alloc(struct rtw_adapter *padapter, struct device *dev)
 	/*  wdev */
 	wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
 	if (!wdev) {
-		DBG_8723A("Couldn't allocate wireless device\n");
 		ret = -ENOMEM;
 		goto free_wiphy;
 	}
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/1456680329-31568-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.