Hello there,

I just ran the sourceforge tool cppcheck over the source code of the
new Linux kernel 2.6.33-rc6

It said

[./i2c/busses/i2c-highlander.c:284]: (style) Warning - using char variable in 
bit operation

The source code is

static int highlander_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr,
                                  unsigned short flags, char read_write,
                                  u8 command, int size,
                                  union i2c_smbus_data *data)
{
        struct highlander_i2c_dev *dev = i2c_get_adapdata(adap);
        int read = read_write & I2C_SMBUS_READ;

In C, chars can be signed or unsigned, so the value written into
local variable read by sign extension is not certain.

Suggest new code

static int highlander_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr,
                                  unsigned short flags, char read_write,
                                  u8 command, int size,
                                  union i2c_smbus_data *data)
{
        struct highlander_i2c_dev *dev = i2c_get_adapdata(adap);
        int read = ((unsigned char) read_write) & I2C_SMBUS_READ;


Regards

David Binderman

                                          
_________________________________________________________________
Tell us your greatest, weirdest and funniest Hotmail stories
http://clk.atdmt.com/UKM/go/195013117/direct/01/--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to