Staging: xgifb: vb_util: Fixed sparse warning of bit truncation due to cast
authorShivani Bhardwaj <shivanib134@gmail.com>
Thu, 1 Oct 2015 21:27:03 +0000 (02:57 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Oct 2015 09:36:00 +0000 (11:36 +0200)
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.

Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/xgifb/vb_util.h

index 7bd395fb31b2816137332f6899bf5a9ec31e1a1b..f613f54d522fe610e9b2b1a245335177d84fab58 100644 (file)
@@ -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);
 }