Skip to contentSkip to conversation

USB: gtco: remove unnecessary variable assignments

PATCH In review Gustavo A. R. Silva 3 participants 3 messages Jun 15, 2017

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

PATCH 1/1 USB: gtco: remove unnecessary variable assignments

Remove unnecessary variable assignments.
Variable _val_ is overwritten before the value stored in it can be used.

Addresses-Coverity-ID: 1397695

---
 drivers/input/tablet/gtco.c | 2 --
 1 file changed, 2 deletions(-)
drivers/input/tablet/gtco.c +0 -2
index b796e89..d9de13c 100644
@@ -652,8 +652,6 @@ static void gtco_urb_callback(struct urb *urbinfo)
 		switch (device->buffer[0]) {
 		case 5:
 			/* Pressure is 9 bits */
-			val = ((u16)(device->buffer[8]) << 1);
-			val |= (u16)(device->buffer[7] >> 7);
 			input_report_abs(inputdev, ABS_PRESSURE,
 					 device->buffer[8]);
 
Signature · 1 line
2.5.0
#1 lore raw
Quoted 14 lines · Gustavo A. R. Silva

Remove unnecessary variable assignments.
Variable _val_ is overwritten before the value stored in it can be used.

Addresses-Coverity-ID: 1397695

---
 drivers/input/tablet/gtco.c | 2 --
 1 file changed, 2 deletions(-)
drivers/input/tablet/gtco.c +0 -0
index b796e89..d9de13c 100644

drivers/input/tablet/gtco.c static void gtco_urb_callback(struct urb *urbinfo) · line 656

Quoted 7 lines
drivers/input/tablet/gtco.c +0 -2
@@ -652,8 +652,6 @@ static void gtco_urb_callback(struct urb *urbinfo)
 		switch (device->buffer[0]) {
 		case 5:
 			/* Pressure is 9 bits */
-			val = ((u16)(device->buffer[8]) << 1);
-			val |= (u16)(device->buffer[7] >> 7);
 			input_report_abs(inputdev, ABS_PRESSURE,
 					 device->buffer[8]);

Perhaps more likely to be

			input_report_abs(inputdev, ABS_PRESSURE, val);
#2 lore raw

Hi Joe, Gustavo,

Quoted 25 lines · Joe Perches
Quoted 14 lines · Gustavo A. R. Silva

Remove unnecessary variable assignments.
Variable _val_ is overwritten before the value stored in it can be used.

Addresses-Coverity-ID: 1397695

---
 drivers/input/tablet/gtco.c | 2 --
 1 file changed, 2 deletions(-)
drivers/input/tablet/gtco.c +0 -0
index b796e89..d9de13c 100644

drivers/input/tablet/gtco.c static void gtco_urb_callback(struct urb *urbinfo) · line 656

Quoted 7 lines
drivers/input/tablet/gtco.c +0 -2
@@ -652,8 +652,6 @@ static void gtco_urb_callback(struct urb *urbinfo)
 		switch (device->buffer[0]) {
 		case 5:
 			/* Pressure is 9 bits */
-			val = ((u16)(device->buffer[8]) << 1);
-			val |= (u16)(device->buffer[7] >> 7);
 			input_report_abs(inputdev, ABS_PRESSURE,
 					 device->buffer[8]);

Perhaps more likely to be

Quoted 1 line
			input_report_abs(inputdev, ABS_PRESSURE, val);

Probably that was the original intention but changing it that way now would give a shift of factor 2 to userspace.

But if the 2 lines are deleted, I would update the comment above it so it is clear the lowest significant bit in buffer[7] is not included in the report call.

Kind regards,
Ulrik