qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] 9pfs-proxy: tiny cleanups in proxy_pwritev and


From: Gonglei
Subject: Re: [Qemu-devel] [PATCH] 9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv
Date: Tue, 10 Mar 2015 15:27:40 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

On 2015/3/10 15:20, Michael Tokarev wrote:
> 10.03.2015 10:15, Gonglei wrote:
>> On 2015/3/10 13:54, Michael Tokarev wrote:
>>> Don't compare syscall return with -1, use "<0" condition.
>>> Don't introduce useless local variables when we already
>>> have similar variable
>>> Rename local variable to be consistent with other usages
>>>
>>> Signed-off-by: Michael Tokarev <address@hidden>
>>> ---
>>>  hw/9pfs/virtio-9p-proxy.c | 12 +++++-------
>>>  1 file changed, 5 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
>>> index 59c7445..a01804a 100644
>>> --- a/hw/9pfs/virtio-9p-proxy.c
>>> +++ b/hw/9pfs/virtio-9p-proxy.c
>>> @@ -696,9 +696,9 @@ static ssize_t proxy_preadv(FsContext *ctx, 
>>> V9fsFidOpenState *fs,
>>>  #ifdef CONFIG_PREADV
>>>      return preadv(fs->fd, iov, iovcnt, offset);
>>>  #else
>>> -    int err = lseek(fs->fd, offset, SEEK_SET);
>>> -    if (err == -1) {
>>> -        return err;
>>> +    int ret = lseek(fs->fd, offset, SEEK_SET);
>>> +    if (err < 0)
>>> +        return ret;
>>
>> The above code fragment is confused.
> 
> Sorry I don't understand, can you elaborate please?
> Note I haven't changed much in there, just variable
> rename and changed the condition within if: s/== -1/< 0/.
> 
You use 'ret' instead of 'err', but remain using 'if (err < 0)',
and missing '{' at the end of if statement.

hw/9pfs/virtio-9p-proxy.c: In function ‘proxy_preadv’:
hw/9pfs/virtio-9p-proxy.c:700: error: ‘err’ undeclared (first use in this 
function)
hw/9pfs/virtio-9p-proxy.c:700: error: (Each undeclared identifier is reported 
only once
hw/9pfs/virtio-9p-proxy.c:700: error: for each function it appears in.)
hw/9pfs/virtio-9p-proxy.c:702: warning: control reaches end of non-void function
hw/9pfs/virtio-9p-proxy.c: At top level:
hw/9pfs/virtio-9p-proxy.c:702: error: expected identifier or ‘(’ before ‘else’
hw/9pfs/virtio-9p-proxy.c:706: error: expected identifier or ‘(’ before ‘}’ 
token
make: *** [hw/9pfs/virtio-9p-proxy.o] Error 1

Regards,
-Gonglei
> (BTW, a code fragment can't be confused, it might be
> confusing I think, with a reader being confused.
> A confused code is um.. something -- a code who doesn't
> know what to do... ;)  Sorry can't resist ;)
> 
> Thanks,
> 
> /mjt
> 





reply via email to

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