From: Stefan Weil Date: Mon, 3 Sep 2012 20:56:00 +0000 (+0200) Subject: hw/wm8750: Fix potential buffer overflow X-Git-Tag: v1.2.1~121 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd4dba66584c36e33195e42ed4d503549b17d4d8;p=thirdparty%2Fqemu.git hw/wm8750: Fix potential buffer overflow Report from smatch: hw/wm8750.c:369 wm8750_tx(12) error: buffer overflow 's->i2c_data' 2 <= 2 It looks like the preprocessor statements were simply misplaced. Replace also __FUNCTION__ by __func__ to please checkpatch.pl. Signed-off-by: Stefan Weil Reviewed-by: Peter Maydell Signed-off-by: Aurelien Jarno (cherry picked from commit 149eeb5fe57b853081e8059575d91b8a58a4f96c) Signed-off-by: Michael Roth --- diff --git a/hw/wm8750.c b/hw/wm8750.c index 11bcec34106..44f138fd51d 100644 --- a/hw/wm8750.c +++ b/hw/wm8750.c @@ -361,10 +361,10 @@ static int wm8750_tx(I2CSlave *i2c, uint8_t data) uint16_t value; if (s->i2c_len >= 2) { - printf("%s: long message (%i bytes)\n", __FUNCTION__, s->i2c_len); #ifdef VERBOSE - return 1; + printf("%s: long message (%i bytes)\n", __func__, s->i2c_len); #endif + return 1; } s->i2c_data[s->i2c_len ++] = data; if (s->i2c_len != 2)