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é <f4...@amsat.org> --- 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