Staging: rtl8723bs: Use kstrto<type> instead of single variable sscanf
PATCH v2 1/1 Staging: rtl8723bs: Use kstrto<type> instead of single variable sscanf
Use kstro<type> instead of single variable sscanf to convert a string to the appropriate integer type. The return value on SUCCESS is 0.
Issue found by checkpatch.pl script:
* Prefer kstrto<type> to single variable sscanf
Signed-off-by Georgiana Chelu <[email protected]>
---
Changes in v2:
* used the right value to check the return value of kstrto<type>
* adjusted the commit message
drivers/staging/rtl8723bs/os_dep/rtw_proc.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/staging/rtl8723bs/os_dep/rtw_proc.c +11 -7
@@ -70,7 +70,11 @@ static ssize_t proc_set_log_level(struct file *file, const char __user *buffer,return -EINVAL ;if (buffer && !copy_from_user (tmp, buffer,sizeof (tmp))) { -sscanf (tmp,"%d " , &log_level); +int num =kstrtoint (tmp,10 , &log_level); + +if (num !=0 ) +return count; +if (log_level >= _drv_always_ && log_level <= _drv_debug_) { GlobalDebugLevel = log_level;
@@ -478,9 +482,9 @@ ssize_t proc_set_odm_dbg_comp(struct file *file, const char __user *buffer, sizeif (buffer && !copy_from_user (tmp, buffer,sizeof (tmp))) { -int num =sscanf (tmp,"%llx" , &dbg_comp); +int num =kstrtoull (tmp,16 , &dbg_comp); -if (num !=1 ) +if (num !=0 )return count;rtw_odm_dbg_comp_set (adapter, dbg_comp);
@@ -512,9 +516,9 @@ ssize_t proc_set_odm_dbg_level(struct file *file, const char __user *buffer, sizif (buffer && !copy_from_user (tmp, buffer,sizeof (tmp))) { -int num =sscanf (tmp,"%u" , &dbg_level); +int num =kstrtouint (tmp,10 , &dbg_level); -if (num !=1 ) +if (num !=0 )return count;rtw_odm_dbg_level_set (adapter, dbg_level);
@@ -546,9 +550,9 @@ static ssize_t proc_set_odm_ability(struct file *file, const char __user *bufferif (buffer && !copy_from_user (tmp, buffer,sizeof (tmp))) { -int num =sscanf (tmp,"%x" , &ability); +int num =kstrtouint (tmp,16 , &ability); -if (num !=1 ) +if (num !=0 )return count;rtw_odm_ability_set (adapter, ability);
Signature · 1 line
2.11.0