qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH -V3 4/8] hw/9pfs: Implement syncfs


From: Aneesh Kumar K. V
Subject: Re: [Qemu-devel] [PATCH -V3 4/8] hw/9pfs: Implement syncfs
Date: Mon, 14 Mar 2011 00:29:56 +0530
User-agent: Notmuch/0.5-66-g70c5e2c (http://notmuchmail.org) Emacs/23.1.1 (i686-pc-linux-gnu)

On Sun, 13 Mar 2011 16:24:13 +0000, Stefan Hajnoczi <address@hidden> wrote:
> On Sat, Mar 5, 2011 at 5:52 PM, Aneesh Kumar K.V
> <address@hidden> wrote:
> > +static void v9fs_post_do_syncfs(V9fsState *s, V9fsPDU *pdu, int err)
> > +{
> > +    if (err == -1) {
> > +        err = -errno;
> > +    }
> 
> errno may have been clobbered by any standard library function/syscall
> invoked by this thread before v9fs_post_do_syncfs() was called.  Why
> not pass the -errno in the function argument?
> 
> static void v9fs_post_do_syncfs(V9fsState *s, V9fsPDU *pdu, int err)
> {
>     complete_pdu(s, pdu, err);
> }
> 
> I strongly suggest doing a separate patch series to clean up of all of
> virtio-9p to stop using errno.  It's bad practice and I've caught
> several errno mistakes in the virtio-9p patches I've reviewed - I bet
> there are other instances lurking around.

Agreed.  I will look at the error handling more closely

> 
> > +static void v9fs_syncfs(V9fsState *s, V9fsPDU *pdu)
> > +{
> > +    int err;
> > +    int32_t fid;
> > +    size_t offset = 7;
> > +    V9fsFidState *fidp;
> > +
> > +    pdu_unmarshal(pdu, offset, "d", &fid);
> > +    fidp = lookup_fid(s, fid);
> > +    if (fidp == NULL) {
> > +        err = -ENOENT;
> > +        v9fs_post_do_syncfs(s, pdu, err);
> > +        return;
> > +    }
> 
> This wasn't setting errno but passed the error in err.  It can stay
> like this if you change v9fs_post_do_syncfs().
> 

nice catch. Will update.

-aneesh



reply via email to

[Prev in Thread] Current Thread [Next in Thread]