* [PATCH][next] SFH: fix error return check for -ERESTARTSYS
@ 2020-10-30 14:30 Colin King
2020-10-30 14:40 ` AW: " Walter Harms
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Colin King @ 2020-10-30 14:30 UTC (permalink / raw)
To: Nehal Shah, Sandeep Singh, Jiri Kosina, Benjamin Tissoires, linux-input
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently the check for the error return code -ERESTARTSYS is dead code
and never executed because a previous check for ret < 0 is catching this
and returning -ETIMEDOUT instead. Fix this by checking for -ERESTARTSYS
before the more generic negative error code.
Addresses-Coverity: ("Logically dead code")
Fixes: 4b2c53d93a4b ("SFH:Transport Driver to add support of AMD Sensor Fusion Hub (SFH)")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/hid/amd-sfh-hid/amd_sfh_hid.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
index a471079a3bd0..4f989483aa03 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
@@ -88,10 +88,10 @@ static int amdtp_wait_for_response(struct hid_device *hid)
ret = wait_event_interruptible_timeout(hid_data->hid_wait,
cli_data->request_done[i],
msecs_to_jiffies(AMD_SFH_RESPONSE_TIMEOUT));
- if (ret < 0)
- return -ETIMEDOUT;
- else if (ret == -ERESTARTSYS)
+ if (ret == -ERESTARTSYS)
return -ERESTARTSYS;
+ else if (ret < 0)
+ return -ETIMEDOUT;
else
return 0;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* AW: [PATCH][next] SFH: fix error return check for -ERESTARTSYS
2020-10-30 14:30 [PATCH][next] SFH: fix error return check for -ERESTARTSYS Colin King
@ 2020-10-30 14:40 ` Walter Harms
2020-11-09 17:08 ` Singh, Sandeep
2020-11-12 15:27 ` Jiri Kosina
2 siblings, 0 replies; 4+ messages in thread
From: Walter Harms @ 2020-10-30 14:40 UTC (permalink / raw)
To: Colin King, Nehal Shah, Sandeep Singh, Jiri Kosina,
Benjamin Tissoires, linux-input
Cc: kernel-janitors, linux-kernel
nit picking:
i would without "else" to improve readability:
if (ret == -ERESTARTSYS)
return -ERESTARTSYS;
if (ret < 0)
return -ETIMEDOUT;
return 0;
jm2c
wh
________________________________________
Von: Colin King <colin.king@canonical.com>
Gesendet: Freitag, 30. Oktober 2020 15:30:02
An: Nehal Shah; Sandeep Singh; Jiri Kosina; Benjamin Tissoires; linux-input@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
Betreff: [PATCH][next] SFH: fix error return check for -ERESTARTSYS
From: Colin Ian King <colin.king@canonical.com>
Currently the check for the error return code -ERESTARTSYS is dead code
and never executed because a previous check for ret < 0 is catching this
and returning -ETIMEDOUT instead. Fix this by checking for -ERESTARTSYS
before the more generic negative error code.
Addresses-Coverity: ("Logically dead code")
Fixes: 4b2c53d93a4b ("SFH:Transport Driver to add support of AMD Sensor Fusion Hub (SFH)")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/hid/amd-sfh-hid/amd_sfh_hid.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
index a471079a3bd0..4f989483aa03 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
@@ -88,10 +88,10 @@ static int amdtp_wait_for_response(struct hid_device *hid)
ret = wait_event_interruptible_timeout(hid_data->hid_wait,
cli_data->request_done[i],
msecs_to_jiffies(AMD_SFH_RESPONSE_TIMEOUT));
- if (ret < 0)
- return -ETIMEDOUT;
- else if (ret == -ERESTARTSYS)
+ if (ret == -ERESTARTSYS)
return -ERESTARTSYS;
+ else if (ret < 0)
+ return -ETIMEDOUT;
else
return 0;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][next] SFH: fix error return check for -ERESTARTSYS
2020-10-30 14:30 [PATCH][next] SFH: fix error return check for -ERESTARTSYS Colin King
2020-10-30 14:40 ` AW: " Walter Harms
@ 2020-11-09 17:08 ` Singh, Sandeep
2020-11-12 15:27 ` Jiri Kosina
2 siblings, 0 replies; 4+ messages in thread
From: Singh, Sandeep @ 2020-11-09 17:08 UTC (permalink / raw)
To: Colin King, Nehal Shah, Sandeep Singh, Jiri Kosina,
Benjamin Tissoires, linux-input
Cc: kernel-janitors, linux-kernel
On 10/30/2020 8:00 PM, Colin King wrote:
> [CAUTION: External Email]
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the check for the error return code -ERESTARTSYS is dead code
> and never executed because a previous check for ret < 0 is catching this
> and returning -ETIMEDOUT instead. Fix this by checking for -ERESTARTSYS
> before the more generic negative error code.
>
> Addresses-Coverity: ("Logically dead code")
> Fixes: 4b2c53d93a4b ("SFH:Transport Driver to add support of AMD Sensor Fusion Hub (SFH)")
Thank you for the patch ..looks good to me.
Reviewed-by: Sandeep Singh <sandeep.singh@amd.com>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/hid/amd-sfh-hid/amd_sfh_hid.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
> index a471079a3bd0..4f989483aa03 100644
> --- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
> @@ -88,10 +88,10 @@ static int amdtp_wait_for_response(struct hid_device *hid)
> ret = wait_event_interruptible_timeout(hid_data->hid_wait,
> cli_data->request_done[i],
> msecs_to_jiffies(AMD_SFH_RESPONSE_TIMEOUT));
> - if (ret < 0)
> - return -ETIMEDOUT;
> - else if (ret == -ERESTARTSYS)
> + if (ret == -ERESTARTSYS)
> return -ERESTARTSYS;
> + else if (ret < 0)
> + return -ETIMEDOUT;
> else
> return 0;
> }
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] SFH: fix error return check for -ERESTARTSYS
2020-10-30 14:30 [PATCH][next] SFH: fix error return check for -ERESTARTSYS Colin King
2020-10-30 14:40 ` AW: " Walter Harms
2020-11-09 17:08 ` Singh, Sandeep
@ 2020-11-12 15:27 ` Jiri Kosina
2 siblings, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2020-11-12 15:27 UTC (permalink / raw)
To: Colin King
Cc: Nehal Shah, Sandeep Singh, Benjamin Tissoires, linux-input,
kernel-janitors, linux-kernel
On Fri, 30 Oct 2020, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the check for the error return code -ERESTARTSYS is dead code
> and never executed because a previous check for ret < 0 is catching this
> and returning -ETIMEDOUT instead. Fix this by checking for -ERESTARTSYS
> before the more generic negative error code.
>
> Addresses-Coverity: ("Logically dead code")
> Fixes: 4b2c53d93a4b ("SFH:Transport Driver to add support of AMD Sensor Fusion Hub (SFH)")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-12 15:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-30 14:30 [PATCH][next] SFH: fix error return check for -ERESTARTSYS Colin King
2020-10-30 14:40 ` AW: " Walter Harms
2020-11-09 17:08 ` Singh, Sandeep
2020-11-12 15:27 ` Jiri Kosina
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).