diff mbox

kvm tools, 9p: Test for tuncation result

Message ID 4DD7ABBA.6090405@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Cyrill Gorcunov May 21, 2011, 12:10 p.m. UTC
Without 'ret' usage I get

 | cyrill@sun kvm $ make
 |  CC       virtio/9p.o
 | virtio/9p.c: In function ‘virtio_p9_wstat’:
 | virtio/9p.c:448:6: error: variable ‘res’ set but not used [-Werror=unused-but-set-variable]
 | cc1: all warnings being treated as errors
 | make: *** [virtio/9p.o] Error 1

so add a basic check for ftruncate result, this eliminate warning and
we might need to use 'res' status later in caller code.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
CC: Sasha Levin <levinsasha928@gmail.com>
---

Pekka, are you fine with 'kvm-tools,9p' prefix?

 tools/kvm/virtio/9p.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Pekka Enberg May 21, 2011, 1:35 p.m. UTC | #1
On Sat, May 21, 2011 at 3:10 PM, Cyrill Gorcunov <gorcunov@gmail.com> wrote:
> Without 'ret' usage I get
>
>  | cyrill@sun kvm $ make
>  |  CC       virtio/9p.o
>  | virtio/9p.c: In function ‘virtio_p9_wstat’:
>  | virtio/9p.c:448:6: error: variable ‘res’ set but not used [-Werror=unused-but-set-variable]
>  | cc1: all warnings being treated as errors
>  | make: *** [virtio/9p.o] Error 1
>
> so add a basic check for ftruncate result, this eliminate warning and
> we might need to use 'res' status later in caller code.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> CC: Sasha Levin <levinsasha928@gmail.com>

Sasha?

> ---
>
> Pekka, are you fine with 'kvm-tools,9p' prefix?

Sure.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sasha Levin May 21, 2011, 2:03 p.m. UTC | #2
On Sat, 2011-05-21 at 16:35 +0300, Pekka Enberg wrote:
> On Sat, May 21, 2011 at 3:10 PM, Cyrill Gorcunov <gorcunov@gmail.com> wrote:
> > Without 'ret' usage I get
> >
> >  | cyrill@sun kvm $ make
> >  |  CC       virtio/9p.o
> >  | virtio/9p.c: In function ‘virtio_p9_wstat’:
> >  | virtio/9p.c:448:6: error: variable ‘res’ set but not used [-Werror=unused-but-set-variable]
> >  | cc1: all warnings being treated as errors
> >  | make: *** [virtio/9p.o] Error 1
> >
> > so add a basic check for ftruncate result, this eliminate warning and
> > we might need to use 'res' status later in caller code.
> >
> > Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> > CC: Sasha Levin <levinsasha928@gmail.com>
> 
> Sasha?

Looks good to me.

Acked-by: Sasha Levin <levinsasha928@gmail.com>

> > ---
> >
> > Pekka, are you fine with 'kvm-tools,9p' prefix?
> 
> Sure.
diff mbox

Patch

Index: linux-2.6.git/tools/kvm/virtio/9p.c
===================================================================
--- linux-2.6.git.orig/tools/kvm/virtio/9p.c
+++ linux-2.6.git/tools/kvm/virtio/9p.c
@@ -445,7 +445,7 @@  static bool virtio_p9_wstat(struct p9_ms
 	struct p9_twstat *twstat = (struct p9_twstat *)msg->msg;
 	struct p9_str *str;
 	struct p9_fid *fid = &p9dev.fids[twstat->fid];
-	int res;
+	int res = 0;

 	if (twstat->stat.length != -1UL)
 		res = ftruncate(fid->fd, twstat->stat.length);
@@ -472,7 +472,8 @@  static bool virtio_p9_wstat(struct p9_ms

 	*outlen = VIRTIO_P9_HDR_LEN;
 	set_p9msg_hdr(outmsg, *outlen, P9_RWSTAT, msg->tag);
-	return true;
+
+	return res == 0;
 }

 static bool virtio_p9_remove(struct p9_msg *msg, u32 len, struct iovec *iov, u32 *outlen)