* [PATCH v3 0/4] Issue suggested by Coccinelle using ret.cocci
@ 2019-03-18 23:12 Madhumitha Prabakaran
2019-03-18 23:12 ` [PATCH v3 1/4] Staging: rtl8723bs: Remove unnecessary local variable in function Madhumitha Prabakaran
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Madhumitha Prabakaran @ 2019-03-18 23:12 UTC (permalink / raw)
To: gregkh, outreachy-kernel; +Cc: Madhumitha Prabakaran
This patchset does tasks as below:
1) Remove unnecessary local variable in function
2) Change values to standard error codes in functions
3) Replace NULL comparison with !
4) Add missing NULL check for kmalloc
All these patches are relevant to an issue suggested by Coccinelle using
ret.cocci.
Madhumitha Prabakaran (4):
Staging: rtl8723bs: Remove unnecessary local variable in function
Staging: rtl8723bs: Change values to standard error codes in functions
Staging: rtl8723bs: Replace NULL comparison with !
Staging: rtl8723bs: Add missing NULL check for kmalloc
Changes in v3-
1) Added one more patch
2) Splitted the changes in two patches
3) Modified a code in patch 2 and changed a commit log
drivers/staging/rtl8723bs/core/rtw_cmd.c | 16 ++++++++--------
drivers/staging/rtl8723bs/os_dep/os_intfs.c | 4 ++--
2 files changed, 10 insertions(+), 10 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/4] Staging: rtl8723bs: Remove unnecessary local variable in function
2019-03-18 23:12 [PATCH v3 0/4] Issue suggested by Coccinelle using ret.cocci Madhumitha Prabakaran
@ 2019-03-18 23:12 ` Madhumitha Prabakaran
2019-03-18 23:12 ` [PATCH v3 2/4] Staging: rtl8723bs: Change values to standard error codes in functions Madhumitha Prabakaran
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Madhumitha Prabakaran @ 2019-03-18 23:12 UTC (permalink / raw)
To: gregkh, outreachy-kernel; +Cc: Madhumitha Prabakaran
Remove unnecessary local variable 'res' in function and
replace the value directly in the return of the function.
Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_cmd.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 9edd9a24756a..b67a5f9c27fa 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -203,8 +203,6 @@ int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
static void c2h_wk_callback(_workitem *work);
int rtw_init_evt_priv(struct evt_priv *pevtpriv)
{
- int res = _SUCCESS;
-
/* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
atomic_set(&pevtpriv->event_seq, 0);
pevtpriv->evt_done_cnt = 0;
@@ -213,7 +211,7 @@ int rtw_init_evt_priv(struct evt_priv *pevtpriv)
pevtpriv->c2h_wk_alive = false;
pevtpriv->c2h_queue = rtw_cbuf_alloc(C2H_QUEUE_MAX_LEN+1);
- return res;
+ return 0;
}
void _rtw_free_evt_priv(struct evt_priv *pevtpriv)
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/4] Staging: rtl8723bs: Change values to standard error codes in functions
2019-03-18 23:12 [PATCH v3 0/4] Issue suggested by Coccinelle using ret.cocci Madhumitha Prabakaran
2019-03-18 23:12 ` [PATCH v3 1/4] Staging: rtl8723bs: Remove unnecessary local variable in function Madhumitha Prabakaran
@ 2019-03-18 23:12 ` Madhumitha Prabakaran
2019-03-18 23:12 ` [PATCH v3 3/4] Staging: rtl8723bs: Replace NULL comparison with ! Madhumitha Prabakaran
2019-03-18 23:12 ` [PATCH v3 4/4] Staging: rtl8723bs: Add missing NULL check for kmalloc Madhumitha Prabakaran
3 siblings, 0 replies; 5+ messages in thread
From: Madhumitha Prabakaran @ 2019-03-18 23:12 UTC (permalink / raw)
To: gregkh, outreachy-kernel; +Cc: Madhumitha Prabakaran
Change values for standard error codes in functions rtw_init_cmd_priv and
rtw_init_evt_priv, as _SUCCESS should be 0 and _FAIL should be -ENOMEM.
Also, change the values in corresponding call sites of the functions.
Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
---
Changes in v3:
Change the commit log and function callsites
---
drivers/staging/rtl8723bs/core/rtw_cmd.c | 6 +++---
drivers/staging/rtl8723bs/os_dep/os_intfs.c | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index b67a5f9c27fa..32d8ff9e41bd 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -164,7 +164,7 @@ No irqsave is necessary.
int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
{
- int res = _SUCCESS;
+ int res = 0;
init_completion(&pcmdpriv->cmd_queue_comp);
init_completion(&pcmdpriv->terminate_cmdthread_comp);
@@ -178,7 +178,7 @@ int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
pcmdpriv->cmd_allocated_buf = rtw_zmalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ);
if (pcmdpriv->cmd_allocated_buf == NULL) {
- res = _FAIL;
+ res = -ENOMEM;
goto exit;
}
@@ -187,7 +187,7 @@ int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
pcmdpriv->rsp_allocated_buf = rtw_zmalloc(MAX_RSPSZ + 4);
if (pcmdpriv->rsp_allocated_buf == NULL) {
- res = _FAIL;
+ res = -ENOMEM;
goto exit;
}
diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index 5c0fbf5170cc..9021bf519605 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -754,7 +754,7 @@ u8 rtw_init_drv_sw(struct adapter *padapter)
rtw_init_hal_com_default_value(padapter);
- if ((rtw_init_cmd_priv(&padapter->cmdpriv)) == _FAIL) {
+ if (rtw_init_cmd_priv(&padapter->cmdpriv)) {
RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init cmd_priv\n"));
ret8 = _FAIL;
goto exit;
@@ -762,7 +762,7 @@ u8 rtw_init_drv_sw(struct adapter *padapter)
padapter->cmdpriv.padapter = padapter;
- if ((rtw_init_evt_priv(&padapter->evtpriv)) == _FAIL) {
+ if (rtw_init_evt_priv(&padapter->evtpriv)) {
RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init evt_priv\n"));
ret8 = _FAIL;
goto exit;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 3/4] Staging: rtl8723bs: Replace NULL comparison with !
2019-03-18 23:12 [PATCH v3 0/4] Issue suggested by Coccinelle using ret.cocci Madhumitha Prabakaran
2019-03-18 23:12 ` [PATCH v3 1/4] Staging: rtl8723bs: Remove unnecessary local variable in function Madhumitha Prabakaran
2019-03-18 23:12 ` [PATCH v3 2/4] Staging: rtl8723bs: Change values to standard error codes in functions Madhumitha Prabakaran
@ 2019-03-18 23:12 ` Madhumitha Prabakaran
2019-03-18 23:12 ` [PATCH v3 4/4] Staging: rtl8723bs: Add missing NULL check for kmalloc Madhumitha Prabakaran
3 siblings, 0 replies; 5+ messages in thread
From: Madhumitha Prabakaran @ 2019-03-18 23:12 UTC (permalink / raw)
To: gregkh, outreachy-kernel; +Cc: Madhumitha Prabakaran
Replace NULL comparison with ! in function rtw_init_cmd_priv, to
maintain Linux kernel coding style.
Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_cmd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 32d8ff9e41bd..9edd0dda3c06 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -177,7 +177,7 @@ int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
pcmdpriv->cmd_allocated_buf = rtw_zmalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ);
- if (pcmdpriv->cmd_allocated_buf == NULL) {
+ if (!pcmdpriv->cmd_allocated_buf) {
res = -ENOMEM;
goto exit;
}
@@ -186,7 +186,7 @@ int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
pcmdpriv->rsp_allocated_buf = rtw_zmalloc(MAX_RSPSZ + 4);
- if (pcmdpriv->rsp_allocated_buf == NULL) {
+ if (!pcmdpriv->rsp_allocated_buf) {
res = -ENOMEM;
goto exit;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 4/4] Staging: rtl8723bs: Add missing NULL check for kmalloc
2019-03-18 23:12 [PATCH v3 0/4] Issue suggested by Coccinelle using ret.cocci Madhumitha Prabakaran
` (2 preceding siblings ...)
2019-03-18 23:12 ` [PATCH v3 3/4] Staging: rtl8723bs: Replace NULL comparison with ! Madhumitha Prabakaran
@ 2019-03-18 23:12 ` Madhumitha Prabakaran
3 siblings, 0 replies; 5+ messages in thread
From: Madhumitha Prabakaran @ 2019-03-18 23:12 UTC (permalink / raw)
To: gregkh, outreachy-kernel; +Cc: Madhumitha Prabakaran
Include missing NULL check for kmalloc in function rtw_init_evt_priv.
Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
---
Change in v3-
Split changes into two different patches in a series.
---
drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 9edd0dda3c06..bd3a5a23a418 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -210,6 +210,8 @@ int rtw_init_evt_priv(struct evt_priv *pevtpriv)
_init_workitem(&pevtpriv->c2h_wk, c2h_wk_callback, NULL);
pevtpriv->c2h_wk_alive = false;
pevtpriv->c2h_queue = rtw_cbuf_alloc(C2H_QUEUE_MAX_LEN+1);
+ if (!pevtpriv->c2h_queue)
+ return -ENOMEM;
return 0;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-03-18 23:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-18 23:12 [PATCH v3 0/4] Issue suggested by Coccinelle using ret.cocci Madhumitha Prabakaran
2019-03-18 23:12 ` [PATCH v3 1/4] Staging: rtl8723bs: Remove unnecessary local variable in function Madhumitha Prabakaran
2019-03-18 23:12 ` [PATCH v3 2/4] Staging: rtl8723bs: Change values to standard error codes in functions Madhumitha Prabakaran
2019-03-18 23:12 ` [PATCH v3 3/4] Staging: rtl8723bs: Replace NULL comparison with ! Madhumitha Prabakaran
2019-03-18 23:12 ` [PATCH v3 4/4] Staging: rtl8723bs: Add missing NULL check for kmalloc Madhumitha Prabakaran
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.