Skip to contentSkip to conversation

input: signedness bug in cma3000_thread_irq()

PATCH Applied Xi Wang 3 participants 7 messages Dec 12, 2011 – Dec 22, 2011

Subsystems (2)
lore
Share & tools
lore

Xi Wang

author
#0 lore raw

PATCH 1/1 input: signedness bug in cma3000_thread_irq()

The error check (intr_status < 0) didn't work because intr_status is a u8. Change its type to signed int.

---
 drivers/input/misc/cma3000_d0x.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/input/misc/cma3000_d0x.c +2 -2
index 80793f1..06517e6 100644
@@ -115,8 +115,8 @@ static void decode_mg(struct cma3000_accl_data *data, int *datax,
 static irqreturn_t cma3000_thread_irq(int irq, void *dev_id)
 {
 	struct cma3000_accl_data *data = dev_id;
-	int datax, datay, dataz;
-	u8 ctrl, mode, range, intr_status;
+	int datax, datay, dataz, intr_status;
+	u8 ctrl, mode, range;
 
 	intr_status = CMA3000_READ(data, CMA3000_INTSTATUS, "interrupt status");
 	if (intr_status < 0)
Signature · 1 line
1.7.5.4
maintainer Applied
#1 lore raw
Quoted 3 lines · Xi Wang

The error check (intr_status < 0) didn't work because intr_status is a u8. Change its type to signed int.

Applied, thank you.

Signature · 1 line
Dmitry
#2 lore raw
In reply to Xi Wang

drivers/input/misc/cma3000_d0x.c

Quoted 9 lines · Xi Wang

The error check (intr_status < 0) didn't work because intr_status is a u8. Change its type to signed int.

---
 drivers/input/misc/cma3000_d0x.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/input/misc/cma3000_d0x.c +0 -0

That will fix the signed/unsigned issue. However, was there a reason the field was an 8-bit-wide to begin with?

author
#3 lore raw
Quoted 2 lines · On Dec 14, 2011, at 9:27 PM, [email protected] wrote:

That will fix the signed/unsigned issue. However, was there a reason the field was an 8-bit-wide to begin with?

Which field? The ->read() function pointer?

- xi

#4 lore raw
Quoted 5 lines · Xi Wang
Quoted 2 lines · On Dec 14, 2011, at 9:27 PM, [email protected] wrote:

That will fix the signed/unsigned issue. However, was there a reason the field was an 8-bit-wide to begin with?

Which field? The ->read() function pointer?

No, the variable that used to be a u8 - was it 8 bits wide for a reason?

author
#5 lore raw
Quoted 1 line · On Dec 14, 2011, at 10:21 PM, [email protected] wrote:

No, the variable that used to be a u8 - was it 8 bits wide for a reason?

The return value of CMA3000_READ? I don't see any particular reason.

- xi

maintainer
#6 lore raw
Quoted 5 lines · Xi Wang
Quoted 1 line · On Dec 14, 2011, at 10:21 PM, [email protected] wrote:

No, the variable that used to be a u8 - was it 8 bits wide for a reason?

The return value of CMA3000_READ? I don't see any particular reason.

The data returned by CMA3000_READ() is a byte, so that's the reason (and I am guessing here) that the author used u8 to store the result, forgetting that the range was extended to report error conditions.

Signature · 1 line
Dmitry