input: signedness bug in cma3000_thread_irq()
Subsystems (2)
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
@@ -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
Quoted 3 lines · Xi Wang
The error check (
intr_status< 0) didn't work becauseintr_statusis a u8. Change its type to signed int.
Applied, thank you.
Signature · 1 line
Dmitry
drivers/input/misc/cma3000_d0x.c
Quoted 9 lines · Xi Wang
The error check (
intr_status< 0) didn't work becauseintr_statusis a u8. Change its type to signed int.Signed-off-by Xi Wang <[email protected]>--- 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?
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
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?
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
Dmitry Torokhov
maintainerQuoted 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