Skip to content

Commit

Permalink
i2c: amd_mp2: handle num is 0 input for i2c_amd_xfer
Browse files Browse the repository at this point in the history
clang static analyzer reports this problem

i2c-amd-mp2-plat.c:174:9: warning: Branch condition evaluates
  to a garbage value
        return err ? err : num;
               ^~~

err is not initialized, it depends on the being set in the
transfer loop which will not happen if num is 0.  Surveying
other master_xfer() implementations show all handle a 0 num.

Because returning 0 is expected, initialize err to 0.

Signed-off-by: Tom Rix <trix@redhat.com>
Acked-by: Elie Morisse <syniurge@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
  • Loading branch information
Tom Rix authored and Wolfram Sang committed Sep 21, 2020
1 parent 703b322 commit 97c93e0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/i2c/busses/i2c-amd-mp2-plat.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static int i2c_amd_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
struct amd_i2c_dev *i2c_dev = i2c_get_adapdata(adap);
int i;
struct i2c_msg *pmsg;
int err;
int err = 0;

/* the adapter might have been deleted while waiting for the bus lock */
if (unlikely(!i2c_dev->common.mp2_dev))
Expand Down

0 comments on commit 97c93e0

Please sign in to comment.