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: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH -V3 4/8] hw/9pfs: Implement syncfs
Date: Sun, 13 Mar 2011 16:24:13 +0000

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.

> +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().

Stefan



reply via email to

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