qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2] linux-user: Use *at functions instead of cac


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v2] linux-user: Use *at functions instead of caching interp_prefix contents
Date: Thu, 7 Dec 2017 11:06:15 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

On 12/07/2017 08:43 AM, Richard Henderson wrote:

>>> -    fd = open(path(filename), O_RDONLY);
>>> +    switch (interp_dirfd > 0 && filename[0] == '/') {
>>> +    case true:
>>
>> gcc doesn't like this pattern:
>>
>> /home/petmay01/linaro/qemu-from-laptop/qemu/linux-user/syscall.c: In
>> function ‘do_name_to_handle_at’:
>> /home/petmay01/linaro/qemu-from-laptop/qemu/linux-user/syscall.c:7231:13:
>> error: switch condition has boolean value [-Werror=switch-bool]
>>      switch (interp_dirfd > 0 && name[0] == '/') {
>>              ^
>>
>> It seems like an odd way to write an if().
> 
> Huh.  My gcc likes it just fine.  What version are you using?
> 
> It's an IF with a /* fallthru */, so there are very few
> less ugly ways to write it...

Maybe:

while (1) {
    if (interp_dirfd > 0 && filename[0] == '/') {
        fd = openat(interp_dirfd, filename + 1, O_RDONLY);
        if (fd >= 0 || errno != ENOENT) {
            break;
        }
    }
    fd = open(filename, O_RDONLY);
    break;
}

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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