drivers: hid: Remove dead storage
PATCH 1/1 drivers: hid: Remove dead storage
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.
---
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(-)
drivers/hid/hid-ntrig.c +1 -1
@@ -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
Quoted 6 lines · Tapasweni Pathak
Remove storing of return value of
ntrig_version_stringfunction to ret as it is a dead storage and not used afterwards.Found using Facebook's Infer. Build tested it.
Quoted 7 lines
Signed-off-by Tapasweni Pathak <[email protected]>---
There is another option to instead check for non zero return value forntrig_version_string()as a successful completion of the function.ntrig_version_string()returns the length of output printed bysprintf()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
Quoted 19 lines
drivers/hid/hid-ntrig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hid/hid-ntrig.c +1
-2@@ -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