[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH for 2.10 11/35] i2c/exynos4210: correctly check i2c_re
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-arm] [PATCH for 2.10 11/35] i2c/exynos4210: correctly check i2c_recv() return value |
Date: |
Mon, 24 Jul 2017 15:27:27 -0300 |
i2c_recv() returns -1 on error, if the I2CCON_ACK_GEN bit was not set this code
was setting i2cds = -1.
i2c/exynos4210_i2c.c:117:20: warning: Loss of sign in implicit conversion
s->i2cds = ret;
^~~
Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/i2c/exynos4210_i2c.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/i2c/exynos4210_i2c.c b/hw/i2c/exynos4210_i2c.c
index c96fa7d7be..4424dbd233 100644
--- a/hw/i2c/exynos4210_i2c.c
+++ b/hw/i2c/exynos4210_i2c.c
@@ -111,10 +111,12 @@ static void exynos4210_i2c_data_receive(void *opaque)
s->i2cstat &= ~I2CSTAT_LAST_BIT;
s->scl_free = false;
ret = i2c_recv(s->bus);
- if (ret < 0 && (s->i2ccon & I2CCON_ACK_GEN)) {
- s->i2cstat |= I2CSTAT_LAST_BIT; /* Data is not acknowledged */
- } else {
+ if (ret >= 0) {
s->i2cds = ret;
+ } else {
+ if (s->i2ccon & I2CCON_ACK_GEN) {
+ s->i2cstat |= I2CSTAT_LAST_BIT; /* Data is not acknowledged */
+ }
}
exynos4210_i2c_raise_interrupt(s);
}
--
2.13.3
- [Qemu-arm] [PATCH for 2.10 11/35] i2c/exynos4210: correctly check i2c_recv() return value,
Philippe Mathieu-Daudé <=