Staging: rtl8188eu: core: rtw_mlme_ext: Use list_for_each_entry_safe
PATCH v2 1/1 Staging: rtl8188eu: core: rtw_mlme_ext: Use list_for_each_entry_safe
This is a cleanup patch and doesn't change runtime behaviour. It changes an open coded list traversal to use list_for_each_entry_safe. Done using the following semantic patch by coccinelle.
@r@
struct list_head* l;
expression e;
identifier m, list_del_init, f;
type T1;
T1* pos;
iterator name list_for_each_entry_safe;
@@
f(...){
+T1* tmp;
<+...
-while(...)
+list_for_each_entry_safe(pos,tmp,l,m)
{
...
-pos = container_of(l,T1,m);
...
-l=e;
<+...
list_del_init(&pos->m)
...+>
}
...+>
}
---
Changes in v2
-Make the commit message more clear.
-Add file name to the subject.
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +3 -5
@@ -5446,6 +5446,7 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf)u8 tx_beacon_hdl (struct adapter *padapter,unsigned char *pbuf) { +struct xmit_frame *tmp;if (send_beacon (padapter) == _FAIL) {DBG_88E ("issue_beacon, fail!\n" );return H2C_PARAMETERS_ERROR ;
@@ -5469,11 +5470,8 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) xmitframe_phead =get_list_head (&psta_bmc->sleep_q); xmitframe_plist = xmitframe_phead->next; -while (xmitframe_phead != xmitframe_plist) { - pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - - xmitframe_plist = xmitframe_plist->next; - +list_for_each_entry_safe (pxmitframe, tmp, + xmitframe_plist, list) {list_del_init (&pxmitframe->list); psta_bmc->sleepq_len--;
Signature · 1 line
2.7.4
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) · line 5450
Quoted 13 lines · Srishti Sharma
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +1
-0@@ -5446,6 +5446,7 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf)u8 tx_beacon_hdl (struct adapter *padapter,unsigned char *pbuf) { +struct xmit_frame *tmp;if (send_beacon (padapter) == _FAIL) {
You need a blank line between the declaration and the code.
regards,
dan carpenter
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Srishti-Sharma/Staging-rtl8188eu-core-rtw_mlme_ext-Use-list_for_each_entry_safe/20171007-080024 config: x86_64-randconfig-v0-10200632 (attached as…
Hi Srishti,
[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v4.14-rc5 next-20171018]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Srishti-Sharma/Staging-rtl8188eu-core-rtw_mlme_ext-Use-list_for_each_entry_safe/20171007-080024
config: x86_64-randconfig-v0-10200632 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7 reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 All warnings (new ones prefixed by >>):
drivers/staging//rtl8188eu/core/rtw_mlme_ext.c: In function 'tx_beacon_hdl':
>> drivers/staging//rtl8188eu/core/rtw_mlme_ext.c:5449: warning: unused variable 'tmp'
vim +/tmp +5449 drivers/staging//rtl8188eu/core/rtw_mlme_ext.c
5446
5447 u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf)
5448 {
> 5449 struct xmit_frame *tmp;
5450 if (send_beacon(padapter) == _FAIL) {
5451 DBG_88E("issue_beacon, fail!\n");
5452 return H2C_PARAMETERS_ERROR;
5453 }
5454 #ifdef CONFIG_88EU_AP_MODE
5455 else { /* tx bc/mc frames after update TIM */
5456 struct sta_info *psta_bmc;
5457 struct list_head *xmitframe_plist, *xmitframe_phead;
5458 struct xmit_frame *pxmitframe = NULL;
5459 struct sta_priv *pstapriv = &padapter->stapriv;
5460
5461 /* for BC/MC Frames */
5462 psta_bmc = rtw_get_bcmc_stainfo(padapter);
5463 if (!psta_bmc)
5464 return H2C_SUCCESS;
5465
5466 if ((pstapriv->tim_bitmap&BIT(0)) && (psta_bmc->sleepq_len > 0)) {
5467 msleep(10);/* 10ms, ATIM(HIQ) Windows */
5468 spin_lock_bh(&psta_bmc->sleep_q.lock);
5469
5470 xmitframe_phead = get_list_head(&psta_bmc->sleep_q);
5471 xmitframe_plist = xmitframe_phead->next;
5472
5473 list_for_each_entry_safe(pxmitframe, tmp,
5474 xmitframe_plist, list) {
5475 list_del_init(&pxmitframe->list);
5476
5477 psta_bmc->sleepq_len--;
5478 if (psta_bmc->sleepq_len > 0)
5479 pxmitframe->attrib.mdata = 1;
5480 else
5481 pxmitframe->attrib.mdata = 0;
5482
5483 pxmitframe->attrib.triggered = 1;
5484
5485 pxmitframe->attrib.qsel = 0x11;/* HIQ */
5486
5487 spin_unlock_bh(&psta_bmc->sleep_q.lock);
5488 if (rtw_hal_xmit(padapter, pxmitframe))
5489 rtw_os_xmit_complete(padapter, pxmitframe);
5490 spin_lock_bh(&psta_bmc->sleep_q.lock);
5491 }
5492 spin_unlock_bh(&psta_bmc->sleep_q.lock);
5493 }
5494 }
5495 #endif
5496 return H2C_SUCCESS;
5497 }
5498
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation