diff mbox

[RESEND] HID: wacom: Remove comparison of u8 mode with zero and simplify.

Message ID 1499541948-3392-1-git-send-email-chris.gekas@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christos Gkekas July 8, 2017, 7:25 p.m. UTC
Variable mode in method wacom_show_remote_mode() is defined as u8, thus
statement (mode >= 0) is always true and should be removed, simplifying
the logic.

Signed-off-by: Christos Gkekas <chris.gekas@gmail.com>
---
 drivers/hid/wacom_sys.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Benjamin Tissoires July 12, 2017, 7:39 a.m. UTC | #1
On Jul 08 2017 or thereabouts, Christos Gkekas wrote:
> Variable mode in method wacom_show_remote_mode() is defined as u8, thus
> statement (mode >= 0) is always true and should be removed, simplifying
> the logic.
> 
> Signed-off-by: Christos Gkekas <chris.gekas@gmail.com>
> ---

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

>  drivers/hid/wacom_sys.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
> index 838c1eb..ae2408d 100644
> --- a/drivers/hid/wacom_sys.c
> +++ b/drivers/hid/wacom_sys.c
> @@ -1671,10 +1671,7 @@ static ssize_t wacom_show_remote_mode(struct kobject *kobj,
>  	u8 mode;
>  
>  	mode = wacom->led.groups[index].select;
> -	if (mode >= 0 && mode < 3)
> -		return snprintf(buf, PAGE_SIZE, "%d\n", mode);
> -	else
> -		return snprintf(buf, PAGE_SIZE, "%d\n", -1);
> +	return sprintf(buf, "%d\n", mode < 3 ? mode : -1);
>  }
>  
>  #define DEVICE_EKR_ATTR_GROUP(SET_ID)					\
> -- 
> 2.7.4
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jiri Kosina July 20, 2017, 1:43 p.m. UTC | #2
On Sat, 8 Jul 2017, Christos Gkekas wrote:

> Variable mode in method wacom_show_remote_mode() is defined as u8, thus
> statement (mode >= 0) is always true and should be removed, simplifying
> the logic.
> 
> Signed-off-by: Christos Gkekas <chris.gekas@gmail.com>

Applied to for-4.14/wacom, thanks.
diff mbox

Patch

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 838c1eb..ae2408d 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1671,10 +1671,7 @@  static ssize_t wacom_show_remote_mode(struct kobject *kobj,
 	u8 mode;
 
 	mode = wacom->led.groups[index].select;
-	if (mode >= 0 && mode < 3)
-		return snprintf(buf, PAGE_SIZE, "%d\n", mode);
-	else
-		return snprintf(buf, PAGE_SIZE, "%d\n", -1);
+	return sprintf(buf, "%d\n", mode < 3 ? mode : -1);
 }
 
 #define DEVICE_EKR_ATTR_GROUP(SET_ID)					\