staging: rtl8723bs: fix brace coding style issues
PATCH 1/1 staging: rtl8723bs: fix brace coding style issues
Remove braces from single line if statements. Also fix a comparsion to NULL in one of the conditions. Issues found by checkpatch.
--- drivers/staging/rtl8723bs/core/rtw_debug.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/core/rtw_debug.c +2 -4
@@ -618,9 +618,8 @@ ssize_t proc_set_wait_hiq_empty(struct file *file, const char __user *buffer, siif (count <1 )return -EFAULT ; -if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp))) { +if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp)))sscanf (tmp,"%u" , &g_wait_hiq_empty); - }return count; }
@@ -1425,9 +1424,8 @@ int proc_get_btcoex_info(struct seq_file *m, void *v) padapter = (struct adapter *)rtw_netdev_priv (dev); pbuf =rtw_zmalloc (bufsize); -if (NULL == pbuf) { +if (!pbuf)return -ENOMEM ; - }rtw_btcoex_DisplayBtCoexInfo (padapter, pbuf, bufsize);
Signature · 1 line
2.17.1
Quoted 14 lines · Michael Straube
Remove braces from single line if statements. Also fix a comparsion to NULL in one of the conditions. Issues found by checkpatch.
Signed-off-by Michael Straube <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_debug.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/staging/rtl8723bs/core/rtw_debug.c +0
-0
drivers/staging/rtl8723bs/core/rtw_debug.c ssize_t proc_set_wait_hiq_empty(struct file *file, const char __user *buffer, si · line 623
Quoted 7 lines
drivers/staging/rtl8723bs/core/rtw_debug.c +1
-2@@ -618,9 +618,8 @@ ssize_t proc_set_wait_hiq_empty(struct file *file, const char __user *buffer, siif (count <1 )return -EFAULT ; -if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp))) { +if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp)))sscanf (tmp,"%u" , &g_wait_hiq_empty); - }
The original code is kind of bad. The NULL check isn't required. The sscanf call should have error checking. The error code is wrong if the copy from user fails. The tmp buffer isn't NUL terminated.
if (copy_from_user(tmp, buffer, sizeof(tmp))) return -EFAULT; tmp[sizeof(tmp) - 1] = '\0'; if (sscanf(tmp, "%u", &g_wait_hiq_empty) != 1) return -EINVAL; return count;
regards,
dan carpenter
Quoted 10 lines · Dan Carpenter
drivers/staging/rtl8723bs/core/rtw_debug.c ssize_t proc_set_wait_hiq_empty(struct file *file, const char __user *buffer, si · line 623
Quoted 7 lines
if (count < 1)
return-EFAULT;drivers/staging/rtl8723bs/core/rtw_debug.c +1
-2-if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp))) { +if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp)))sscanf (tmp,"%u" , &g_wait_hiq_empty); - }The original code is kind of bad. The NULL check isn't required.
Just for clarification, NULL check refers to checking if buffer != NULL in the if condition?
if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp)))
~~~~~~Quoted 12 lines
The sscanf call should have error checking. The error code is wrong if the copy from user fails. The tmp buffer isn't NUL terminated.
if (copy_from_user(tmp, buffer, sizeof(tmp))) return -EFAULT; tmp[sizeof(tmp) - 1] = '\0'; if (sscanf(tmp, "%u", &g_wait_hiq_empty) != 1) return -EINVAL; return count;
Quoted 3 lines
regards,
dan carpenter
Regards,
Michael
Quoted 11 lines · Michael Straube
Quoted 9 lines · Dan Carpenter
drivers/staging/rtl8723bs/core/rtw_debug.c ssize_t proc_set_wait_hiq_empty(struct file *file, const char __user *buffer, si · line 623
Quoted 6 lines
if (count < 1)
return-EFAULT;drivers/staging/rtl8723bs/core/rtw_debug.c +1
-2-if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp))) { +if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp)))sscanf (tmp,"%u" , &g_wait_hiq_empty); - }The original code is kind of bad. The NULL check isn't required.
Quoted 5 lines
Just for clarification, NULL check refers to checking if buffer != NULL in the if condition?
if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) ~~~~~~
Yes. If buffer is NULL that's just another invalid pointer which the user cannot access, it's not special, and the copy will fail.
regards,
dan carpenter
Quoted 28 lines · Dan Carpenter
Quoted 14 lines · Michael Straube
Remove braces from single line if statements. Also fix a comparsion to NULL in one of the conditions. Issues found by checkpatch.
Signed-off-by Michael Straube <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_debug.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/staging/rtl8723bs/core/rtw_debug.c +0
-0drivers/staging/rtl8723bs/core/rtw_debug.c ssize_t proc_set_wait_hiq_empty(struct file *file, const char __user *buffer, si · line 623
Quoted 7 lines
drivers/staging/rtl8723bs/core/rtw_debug.c +1
-2@@ -618,9 +618,8 @@ ssize_t proc_set_wait_hiq_empty(struct file *file, const char __user *buffer, siif (count <1 )return -EFAULT ; -if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp))) { +if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp)))sscanf (tmp,"%u" , &g_wait_hiq_empty); - }The original code is kind of bad. The NULL check isn't required. The sscanf call should have error checking. The error code is wrong if the copy from user fails. The tmp buffer isn't NUL terminated.
Quoted 8 lines
if (copy_from_user(tmp, buffer, sizeof(tmp)))
return -EFAULT;
tmp[sizeof(tmp) - 1] = '\0';
if (sscanf(tmp, "%u", &g_wait_hiq_empty) != 1)
return -EINVAL;
return count;Shouldn't this be
kstrtouint_from_user()
instead of all those lines?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 36 lines · Andy Shevchenko
Quoted 35 lines · Dan Carpenter
Quoted 14 lines · Michael Straube
Remove braces from single line if statements. Also fix a comparsion to NULL in one of the conditions. Issues found by checkpatch.
Signed-off-by Michael Straube <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_debug.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/staging/rtl8723bs/core/rtw_debug.c +0
-0drivers/staging/rtl8723bs/core/rtw_debug.c ssize_t proc_set_wait_hiq_empty(struct file *file, const char __user *buffer, si · line 623
Quoted 7 lines
drivers/staging/rtl8723bs/core/rtw_debug.c +1
-2@@ -618,9 +618,8 @@ ssize_t proc_set_wait_hiq_empty(struct file *file, const char __user *buffer, siif (count <1 )return -EFAULT ; -if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp))) { +if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp)))sscanf (tmp,"%u" , &g_wait_hiq_empty); - }The original code is kind of bad. The NULL check isn't required. The sscanf call should have error checking. The error code is wrong if the copy from user fails. The tmp buffer isn't NUL terminated.
if (copy_from_user(tmp, buffer, sizeof(tmp))) return -EFAULT; tmp[sizeof(tmp) - 1] = '\0'; if (sscanf(tmp, "%u", &g_wait_hiq_empty) != 1) return -EINVAL;
Quoted 7 lines
Quoted 1 line
return count;Shouldn't this be
kstrtouint_from_user()instead of all those lines?
I wasn't sure kstrtoint() was the exact same as sscanf()... If so then sure.
regards,
dan carpenter
Quoted 32 lines · Dan Carpenter
Quoted 31 lines · Andy Shevchenko
Quoted 29 lines · Dan Carpenter
Quoted 7 lines · Michael Straube
Remove braces from single line if statements. Also fix a comparsion to NULL in one of the conditions. Issues found by checkpatch.
drivers/staging/rtl8723bs/core/rtw_debug.c ssize_t proc_set_wait_hiq_empty(struct file *file, const char __user *buffer, si · line 623
Quoted 7 lines
drivers/staging/rtl8723bs/core/rtw_debug.c +1
-2@@ -618,9 +618,8 @@ ssize_t proc_set_wait_hiq_empty(struct file *file, const char __user *buffer, siif (count <1 )return -EFAULT ; -if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp))) { +if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp)))sscanf (tmp,"%u" , &g_wait_hiq_empty); - }The original code is kind of bad. The NULL check isn't required. The sscanf call should have error checking. The error code is wrong if the copy from user fails. The tmp buffer isn't NUL terminated.
if (copy_from_user(tmp, buffer, sizeof(tmp))) return -EFAULT; tmp[sizeof(tmp) - 1] = '\0'; if (sscanf(tmp, "%u", &g_wait_hiq_empty) != 1) return -EINVAL; return count;
Quoted 8 lines
Quoted 5 lines
Shouldn't this be
kstrtouint_from_user()instead of all those lines?
I wasn't sure
kstrtoint()was the exact same assscanf()... If so then sure.
In this case it's very close to what sscanf() is doing here including all user buffer handing.
Signature · 2 lines
With Best Regards, Andy Shevchenko