From: Greg Kurz <groug@kaod.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Greg Kurz" <groug@kaod.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [Qemu-devel] [PULL v2 1/4] 9pfs: avoid sign conversion error simplifying the code
Date: Tue, 5 Sep 2017 18:00:24 +0200 [thread overview]
Message-ID: <20170905160027.15081-2-groug@kaod.org> (raw)
In-Reply-To: <20170905160027.15081-1-groug@kaod.org>
From: Philippe Mathieu-Daudé <f4bug@amsat.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é <f4bug@amsat.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
---
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 333dbb6f8ee2..0a37c8bd1361 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.5
next prev parent reply other threads:[~2017-09-05 16:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-05 16:00 [Qemu-devel] [PULL v2 0/4] 9pfs/virtfs patches for 2.11 20170905 Greg Kurz
2017-09-05 16:00 ` Greg Kurz [this message]
2017-09-05 16:00 ` [Qemu-devel] [PULL v2 2/4] fsdev: fix memory leak in main() Greg Kurz
2017-09-05 16:00 ` [Qemu-devel] [PULL v2 3/4] 9pfs: local: clarify fchmodat_nofollow() implementation Greg Kurz
2017-09-05 16:00 ` [Qemu-devel] [PULL v2 4/4] virtfs: error out gracefully when mandatory suboptions are missing Greg Kurz
2017-09-05 17:12 ` [Qemu-devel] [PULL v2 0/4] 9pfs/virtfs patches for 2.11 20170905 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170905160027.15081-2-groug@kaod.org \
--to=groug@kaod.org \
--cc=f4bug@amsat.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).