* [PATCH] drivers: hid: Remove dead storage
@ 2018-09-29 16:06 Tapasweni Pathak
2018-10-01 8:33 ` Benjamin Tissoires
0 siblings, 1 reply; 2+ messages in thread
From: Tapasweni Pathak @ 2018-09-29 16:06 UTC (permalink / raw)
To: jikos, benjamin.tissoires, linux-input, linux-kernel
Remove storing of return value of ntrig_version_string function
to ret as it is a dead storage and not used afterwards.
Found using Facebook's Infer. Build tested it.
Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
---
There is another option to instead check for non zero return
value for ntrig_version_string() as a successful completion
of the function. ntrig_version_string() returns the length
of output printed by sprintf() after converting the raw firmware
code into a 5 comma separated numbers.
drivers/hid/hid-ntrig.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index 43b1c72..22aebf4 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -159,7 +159,7 @@ static void ntrig_report_version(struct hid_device *hdev)
USB_CTRL_SET_TIMEOUT);
if (ret == 8) {
- ret = ntrig_version_string(&data[2], buf);
+ ntrig_version_string(&data[2], buf);
hid_info(hdev, "Firmware version: %s (%02x%02x %02x%02x)\n",
buf, data[2], data[3], data[4], data[5]);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drivers: hid: Remove dead storage
2018-09-29 16:06 [PATCH] drivers: hid: Remove dead storage Tapasweni Pathak
@ 2018-10-01 8:33 ` Benjamin Tissoires
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Tissoires @ 2018-10-01 8:33 UTC (permalink / raw)
To: tapaswenipathak; +Cc: Jiri Kosina, open list:HID CORE LAYER, lkml
On Sat, Sep 29, 2018 at 6:06 PM Tapasweni Pathak
<tapaswenipathak@gmail.com> wrote:
>
> Remove storing of return value of ntrig_version_string function
> to ret as it is a dead storage and not used afterwards.
>
> Found using Facebook's Infer. Build tested it.
>
> Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
> ---
> There is another option to instead check for non zero return
> value for ntrig_version_string() as a successful completion
> of the function. ntrig_version_string() returns the length
> of output printed by sprintf() after converting the raw firmware
> code into a 5 comma separated numbers.
If you really want to fix this, I would prefer the alternative above.
Just one nitpick: please make sure ntrig_version_string() returns
either 0 (success) or a negative error.
Then in ntrig_report_version(), if the returned value is non null,
output a hid_warn() instead of leaking a non allocated buffer.
Cheers,
Benjamin
>
> drivers/hid/hid-ntrig.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
> index 43b1c72..22aebf4 100644
> --- a/drivers/hid/hid-ntrig.c
> +++ b/drivers/hid/hid-ntrig.c
> @@ -159,7 +159,7 @@ static void ntrig_report_version(struct hid_device *hdev)
> USB_CTRL_SET_TIMEOUT);
>
> if (ret == 8) {
> - ret = ntrig_version_string(&data[2], buf);
> + ntrig_version_string(&data[2], buf);
>
> hid_info(hdev, "Firmware version: %s (%02x%02x %02x%02x)\n",
> buf, data[2], data[3], data[4], data[5]);
> --
> 2.7.4
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-01 8:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-29 16:06 [PATCH] drivers: hid: Remove dead storage Tapasweni Pathak
2018-10-01 8:33 ` Benjamin Tissoires
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).