Re: [PATCH 01/26] usb: gadget: fsl: remove usage of list iterator past the loop body

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

 



On Sun, Mar 6, 2022 at 9:51 AM Jakob Koschel <jakobkoschel@xxxxxxxxx> wrote:
>
>         /* make sure it's actually queued on this endpoint */
> -       list_for_each_entry(req, &ep->queue, queue) {
> -               if (&req->req == _req)
> +       list_for_each_entry(tmp, &ep->queue, queue) {
> +               if (&tmp->req == _req) {
> +                       req = tmp;
>                         break;
> +               }
>         }

Honestly, I think many (most?) of these would be a lot cleaner as

        list_for_each_entry(tmp, &ep->queue, queue) {
                if (&tmp->req != _req)
                        continue;
                req = tmp;
                break;
        }

and in fact maybe that 'tmp' would be better named 'iter' or similar
(maybe 'pos', which is what the list.h macros themselves use for the
iterator naming), just from a naming standpoint.

Because it's not really some temporary variable, it has a real use.

           Linus



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux