Re: [PATCH 08/10] mmc: block: respect bool returned from blk_end_request()

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

 



On 6 February 2017 at 10:07, Arnd Bergmann <arnd@xxxxxxxx> wrote:
> On Fri, Feb 3, 2017 at 1:57 PM, Linus Walleij <linus.walleij@xxxxxxxxxx> wrote:
>>>>         if (mmc_card_removed(card))
>>>>                 req->rq_flags |= RQF_QUIET;
>>>> -       while (ret)
>>>> -               ret = blk_end_request(req, -EIO,
>>>> -                                     blk_rq_cur_bytes(req));
>>>> +       while (blk_end_request(req, -EIO, blk_rq_cur_bytes(req)))
>>>> +       {
>>>> +       }
>>>
>>> These brackets isn't needed, so am going to change this before applying.
>>>
>>> while (blk_end_request(req, -EIO, blk_rq_cur_bytes(req)));
>>
>> Aha you know your C syntax better than me. Looks like something that
>> checkpatch should catch actually, but I ran this through checkpatch and
>> it didn't complain.
>
> IIRC gcc-7 will warn about Ulf's version, as it is a bit misleading and can
> lead to subtle bugs like
>
>    int ret = 0;
>    while (!ret);
>         ret = do_something();
>
> which would pass a casual review but is actually an endless loop.
>
>     Arnd

Okay, seems reasonable. However mine version is already being used at
some places in the kernel.

Linus version, was actually complained by checkpatch. Perhaps me an
Linus ran different versions of check patch.

So, then which version is preferred here?

Perhaps something like this is the best?

while (1) {
     ret = do_something();
     if (!ret)
         break;
}

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



[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux