Skip to contentSkip to conversation

Staging: xgifb: vb_util: Fixed sparse warning of bit truncation due to cast

PATCH New Shivani Bhardwaj 1 participant 1 message Oct 1, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: xgifb: vb_util: Fixed sparse warning of bit truncation due to cast

Fixed the warning generated by sparse that 'cast truncates bits from constant value' by typecasting unsigned values to u8 as their logical operation is being performed with and stored in a u8 type variable.

---
 drivers/staging/xgifb/vb_util.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/xgifb/vb_util.h +2 -2
index 7bd395f..f613f54 100644
@@ -18,7 +18,7 @@ static inline void xgifb_reg_and_or(unsigned long port, u8 index,
 	u8 temp;
 
 	temp = xgifb_reg_get(port, index);
-	temp = (temp & data_and) | data_or;
+	temp = (u8) ((temp & data_and) | data_or);
 	xgifb_reg_set(port, index, temp);
 }
 
@@ -27,7 +27,7 @@ static inline void xgifb_reg_and(unsigned long port, u8 index, unsigned data_and
 	u8 temp;
 
 	temp = xgifb_reg_get(port, index);
-	temp &= data_and;
+	temp = (u8) (temp & data_and);
 	xgifb_reg_set(port, index, temp);
 }
 
Signature · 1 line
2.1.0