Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1683640 > unrolled thread

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

Started byChristos Gkekas <chris.gekas@gmail.com>
First post2017-07-08 21:30 +0200
Last post2017-07-12 09:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH RESEND] HID: wacom: Remove comparison of u8 mode with zero and simplify. Christos Gkekas <chris.gekas@gmail.com> - 2017-07-08 21:30 +0200
    Re: [PATCH RESEND] HID: wacom: Remove comparison of u8 mode with  zero and simplify. Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-07-12 09:40 +0200

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

FromChristos Gkekas <chris.gekas@gmail.com>
Date2017-07-08 21:30 +0200
Subject[PATCH RESEND] HID: wacom: Remove comparison of u8 mode with zero and simplify.
Message-ID<u13At-69U-1@gated-at.bofh.it>
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(-)

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

[toc] | [next] | [standalone]


#1685572 — Re: [PATCH RESEND] HID: wacom: Remove comparison of u8 mode with zero and simplify.

FromBenjamin Tissoires <benjamin.tissoires@redhat.com>
Date2017-07-12 09:40 +0200
SubjectRe: [PATCH RESEND] HID: wacom: Remove comparison of u8 mode with zero and simplify.
Message-ID<u2kpA-5f6-23@gated-at.bofh.it>
In reply to#1683640
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
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web