From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daYlt-0005y6-So for qemu-devel@nongnu.org; Wed, 26 Jul 2017 22:43:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daYlt-0008I3-47 for qemu-devel@nongnu.org; Wed, 26 Jul 2017 22:43:29 -0400 Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 26 Jul 2017 23:42:22 -0300 Message-Id: <20170727024224.22900-18-f4bug@amsat.org> In-Reply-To: <20170727024224.22900-1-f4bug@amsat.org> References: <20170727024224.22900-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH for 2.10 v2 18/20] 9pfs: avoid sign conversion error simplifying the code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Eric Blake , "Aneesh Kumar K . V" , Greg Kurz Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, qemu-trivial@nongnu.org (note this is how other functions also handle the errors). hw/9pfs/9p.c:948:18: warning: Loss of sign in implicit conversion offset = err; ^~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé --- hw/9pfs/9p.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 333dbb6f8e..0a37c8bd13 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -945,7 +945,6 @@ static void coroutine_fn v9fs_version(void *opaque) v9fs_string_init(&version); err = pdu_unmarshal(pdu, offset, "ds", &s->msize, &version); if (err < 0) { - offset = err; goto out; } trace_v9fs_version(pdu->tag, pdu->id, s->msize, version.data); @@ -962,13 +961,12 @@ static void coroutine_fn v9fs_version(void *opaque) err = pdu_marshal(pdu, offset, "ds", s->msize, &version); if (err < 0) { - offset = err; goto out; } - offset += err; + err += offset; trace_v9fs_version_return(pdu->tag, pdu->id, s->msize, version.data); out: - pdu_complete(pdu, offset); + pdu_complete(pdu, err); v9fs_string_free(&version); } -- 2.13.3