Skip to contentSkip to conversation

Input: cyttsp4 - silence shift wrap warning

PATCH Applied Dan Carpenter 2 participants 2 messages Jul 2, 2013 – Jul 3, 2013

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

PATCH 1/3 Input: cyttsp4 - silence shift wrap warning

"*max" is a size_t (long) type but "1" is an int so static checkers complain that the shift could wrap.

drivers/input/touchscreen/cyttsp4_core.c +1 -1
index 963da05..7aa4a34 100644
@@ -153,7 +153,7 @@ static int cyttsp4_hw_reset(struct cyttsp4 *cd)
  */
 static int cyttsp4_bits_2_bytes(unsigned int nbits, size_t *max)
 {
-	*max = 1 << nbits;
+	*max = 1UL << nbits;
 	return (nbits + 7) / 8;
 }
 
maintainer Applied
#1 lore raw
Quoted 4 lines · Dan Carpenter

"*max" is a size_t (long) type but "1" is an int so static checkers complain that the shift could wrap.

Applied all 3, thank you Dan.

Quoted 14 lines
drivers/input/touchscreen/cyttsp4_core.c +1 -1
index 963da05..7aa4a34 100644
@@ -153,7 +153,7 @@ static int cyttsp4_hw_reset(struct cyttsp4 *cd)
  */
 static int cyttsp4_bits_2_bytes(unsigned int nbits, size_t *max)
 {
-	*max = 1 << nbits;
+	*max = 1UL << nbits;
 	return (nbits + 7) / 8;
 }
 
Signature · 1 line
Dmitry