From: Michael Tokarev Date: Sat, 14 Sep 2013 09:11:36 +0000 (+0400) Subject: iov: avoid "orig_len may be used unitialized" warning X-Git-Tag: qemu-xen-4.4.0-rc1~1^2~9 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b314120afdbab3d29885f47fc83bc55f43765968;p=qemu-upstream-4.4-testing.git iov: avoid "orig_len may be used unitialized" warning Signed-off-by: Wenchao Xia Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael Tokarev (cherry picked from commit 2be178a475289286db80de5ddd7830e67e112bdd) Signed-off-by: Michael Roth --- diff --git a/util/iov.c b/util/iov.c index f70558680..bb46c04e4 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;