diff options
author | Tom Rix <trix@redhat.com> | 2020-09-04 11:06:47 -0700 |
---|---|---|
committer | Wolfram Sang <wsa@kernel.org> | 2020-09-21 11:45:43 +0200 |
commit | 97c93e06f506107362f1630aa25ec3e3ae71d070 (patch) | |
tree | 1d26f1dd1a394a901c25f8b48aaa66c5531a6dc1 | |
parent | 703b3228a8fffcadf4651fde527a1b68c693e3a1 (diff) |
i2c: amd_mp2: handle num is 0 input for i2c_amd_xfer
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>
-rw-r--r-- | drivers/i2c/busses/i2c-amd-mp2-plat.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-amd-mp2-plat.c b/drivers/i2c/busses/i2c-amd-mp2-plat.c index 17df9e8845b6..506433bc0ff2 100644 --- a/drivers/i2c/busses/i2c-amd-mp2-plat.c +++ b/drivers/i2c/busses/i2c-amd-mp2-plat.c @@ -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)) |