linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* i2c/busses/i2c-highlander.c: using char variable in bit operation
@ 2010-02-01  9:51 d binderman
       [not found] ` <BLU108-W10538CE8A7EF6373FB36AE9C580-MsuGFMq8XAE@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: d binderman @ 2010-02-01  9:51 UTC (permalink / raw)
  To: khali-PUYAD+kWke1g9hUCZPvPmw; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA



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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-02-02 14:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-01  9:51 i2c/busses/i2c-highlander.c: using char variable in bit operation d binderman
     [not found] ` <BLU108-W10538CE8A7EF6373FB36AE9C580-MsuGFMq8XAE@public.gmane.org>
2010-02-01 10:07   ` Jean Delvare
     [not found]     ` <20100201110721.461fd142-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-02-01 10:15       ` Wolfram Sang
     [not found]         ` <20100201101509.GB3288-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-02-02 12:17           ` [PATCH] i2c/highlander: remover superflous variable Wolfram Sang
     [not found]             ` <1265113063-22894-1-git-send-email-w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-02-02 12:29               ` Jean Delvare
2010-02-02 14:31               ` Paul Mundt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).