kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtw88: Fix an error code in rtw_debugfs_set_rsvd_page()
@ 2021-02-16 19:43 Dan Carpenter
  2021-03-15  8:08 ` Kalle Valo
       [not found] ` <20210315080817.A3975C43461@smtp.codeaurora.org>
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-02-16 19:43 UTC (permalink / raw)
  To: Yan-Hsuan Chuang
  Cc: Kalle Valo, Tzu-En Huang, linux-wireless, kernel-janitors

The sscanf() function returns either 0 or 1 here.  It doesn't return
error codes.  We should return -EINVAL if the string is invalid.

Fixes: c376c1fc87b7 ("rtw88: add h2c command in debugfs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/wireless/realtek/rtw88/debug.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c
index 948cb79050ea..99be7fcb5d71 100644
--- a/drivers/net/wireless/realtek/rtw88/debug.c
+++ b/drivers/net/wireless/realtek/rtw88/debug.c
@@ -262,15 +262,12 @@ static ssize_t rtw_debugfs_set_rsvd_page(struct file *filp,
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 	char tmp[32 + 1];
 	u32 offset, page_num;
-	int num;
 
 	rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2);
 
-	num = sscanf(tmp, "%d %d", &offset, &page_num);
-
-	if (num != 2) {
+	if (sscanf(tmp, "%d %d", &offset, &page_num) != 2) {
 		rtw_warn(rtwdev, "invalid arguments\n");
-		return num;
+		return -EINVAL;
 	}
 
 	debugfs_priv->rsvd_page.page_offset = offset;
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rtw88: Fix an error code in rtw_debugfs_set_rsvd_page()
  2021-02-16 19:43 [PATCH] rtw88: Fix an error code in rtw_debugfs_set_rsvd_page() Dan Carpenter
@ 2021-03-15  8:08 ` Kalle Valo
       [not found] ` <20210315080817.A3975C43461@smtp.codeaurora.org>
  1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2021-03-15  8:08 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Yan-Hsuan Chuang, Tzu-En Huang, linux-wireless, kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> wrote:

> The sscanf() function returns either 0 or 1 here.  It doesn't return
> error codes.  We should return -EINVAL if the string is invalid.
> 
> Fixes: c376c1fc87b7 ("rtw88: add h2c command in debugfs")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Why do you remove the num variable? I think the code is more readable with it.

(Sorry, I'm not able to quote the code as I'm replying from patchwork script
and it doesn't support that yet.)

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/YCwgb/4F4Y+tyE56@mwanda/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rtw88: Fix an error code in rtw_debugfs_set_rsvd_page()
       [not found] ` <20210315080817.A3975C43461@smtp.codeaurora.org>
@ 2021-03-15  9:11   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-03-15  9:11 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Yan-Hsuan Chuang, Tzu-En Huang, linux-wireless, kernel-janitors

On Mon, Mar 15, 2021 at 08:08:17AM +0000, Kalle Valo wrote:
> Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> > The sscanf() function returns either 0 or 1 here.  It doesn't return
> > error codes.  We should return -EINVAL if the string is invalid.
> > 
> > Fixes: c376c1fc87b7 ("rtw88: add h2c command in debugfs")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Why do you remove the num variable? I think the code is more readable with it.
> 

The way I wrote it is slightly more normal (457 vs 333) and we don't use
"num" except for the one if statement.  But I can write the other way.
I'll resend.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-15  9:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-16 19:43 [PATCH] rtw88: Fix an error code in rtw_debugfs_set_rsvd_page() Dan Carpenter
2021-03-15  8:08 ` Kalle Valo
     [not found] ` <20210315080817.A3975C43461@smtp.codeaurora.org>
2021-03-15  9:11   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).