Skip to contentSkip to conversation

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

PATCH RESEND Applied Christos Gkekas 3 participants 3 messages Jul 8, 2017 – Jul 20, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 HID: wacom: Remove comparison of u8 mode with zero and simplify.

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.

---
 drivers/hid/wacom_sys.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/hid/wacom_sys.c +1 -4
index 838c1eb..ae2408d 100644
@@ -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)					\
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Christos Gkekas

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.

---

Quoted 22 lines
 drivers/hid/wacom_sys.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/hid/wacom_sys.c +1 -4
index 838c1eb..ae2408d 100644
@@ -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)					\
Signature · 1 line
2.7.4