9pfs: avoid sign conversion error simplifying the code
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>
Wed, 9 Aug 2017 14:32:46 +0000 (16:32 +0200)
committerGreg Kurz <groug@kaod.org>
Tue, 5 Sep 2017 12:01:16 +0000 (14:01 +0200)
(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

index 333dbb6f8ee28c8425783506ceeb20d431cc7a93..0a37c8bd13618bc07d875456dddbe6921a71607c 100644 (file)
@@ -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);
 }