Patchwork [V3] build: remove compile warning

login
register
mail settings
Submitter Wayne Xia
Date June 14, 2013, 11:53 a.m.
Message ID <1371210780-16258-1-git-send-email-xiawenc@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/251410/
State New
Headers show

Comments

Wayne Xia - June 14, 2013, 11:53 a.m.
This patch simply remove "variable may be used uninitialized" warning.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
V2: Address Stefan and Peter's comments, use 0 in send_msg() instead of
initialize mhHeader.
V3: Address Markus's comments, adjust the code section in iov.c.

 libcacard/vscclient.c |    3 +--
 util/iov.c            |   10 ++++------
 2 files changed, 5 insertions(+), 8 deletions(-)
Stefan Hajnoczi - June 17, 2013, 11:34 a.m.
On Fri, Jun 14, 2013 at 07:53:00PM +0800, Wenchao Xia wrote:
> This patch simply remove "variable may be used uninitialized" warning.
> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
> V2: Address Stefan and Peter's comments, use 0 in send_msg() instead of
> initialize mhHeader.
> V3: Address Markus's comments, adjust the code section in iov.c.
> 
>  libcacard/vscclient.c |    3 +--
>  util/iov.c            |   10 ++++------
>  2 files changed, 5 insertions(+), 8 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

Patch

diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
index ac23647..7fbf1da 100644
--- a/libcacard/vscclient.c
+++ b/libcacard/vscclient.c
@@ -641,7 +641,6 @@  main(
     GIOChannel *channel_stdin;
     char *qemu_host;
     char *qemu_port;
-    VSCMsgHeader mhHeader;
 
     VCardEmulOptions *command_line_options = NULL;
 
@@ -750,7 +749,7 @@  main(
         .magic = VSCARD_MAGIC,
         .capabilities = {0}
     };
-    send_msg(VSC_Init, mhHeader.reader_id, &init, sizeof(init));
+    send_msg(VSC_Init, 0, &init, sizeof(init));
 
     g_main_loop_run(loop);
     g_main_loop_unref(loop);
diff --git a/util/iov.c b/util/iov.c
index cc6e837..50938e1 100644
--- a/util/iov.c
+++ b/util/iov.c
@@ -181,13 +181,11 @@  ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
             assert(iov[niov].iov_len > tail);
             orig_len = iov[niov].iov_len;
             iov[niov++].iov_len = tail;
-        }
-
-        ret = do_send_recv(sockfd, iov, niov, do_send);
-
-        /* Undo the changes above before checking for errors */
-        if (tail) {
+            ret = do_send_recv(sockfd, iov, niov, do_send);
+            /* Undo the changes above before checking for errors */
             iov[niov-1].iov_len = orig_len;
+        } else {
+            ret = do_send_recv(sockfd, iov, niov, do_send);
         }
         if (offset) {
             iov[0].iov_base -= offset;