lkml.org 
[lkml]   [2022]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RESEND PATCH 05/11] platform/chrome: cros_ec_proto: separate cros_ec_wait_until_complete()
On Thu, Jul 14, 2022 at 07:29:45AM -0700, Guenter Roeck wrote:
> On Wed, Jul 13, 2022 at 8:33 PM Tzung-Bi Shih <tzungbi@kernel.org> wrote:
> > On Wed, Jul 13, 2022 at 11:15:47AM -0700, Guenter Roeck wrote:
> > > On Mon, Jun 27, 2022 at 7:49 PM Tzung-Bi Shih <tzungbi@kernel.org> wrote:
> > > > + ret = cros_ec_xfer_command(ec_dev, msg);
> > > > + if (ret == -EAGAIN)
> > > > + continue;
> > > > + if (ret < 0)
> > > > + break;
> > >
> > > With the command allocated on the stack, this can return immediately.
> >
> > Nack, the function has no goto labels. `return ret` follows the loop
> > immediately. The `break` here doesn't make it to become too complicated.
> > I would prefer to keep it.
>
> Sorry, you lost me here. The code after the loop does
>
> kfree(msg);
> return ret;
>
> If kfree() is no longer necessary, only the return statement is left. So break;
> is identical to return ret;. Am I missing something ?

You are correct.

I meant personally I would prefer to use `break`:
* The loop is short so that it won't become too complicated.
* Keep the function has a single exit point.

But, anyway, let's use `return ret` to make it explicit.

\
 
 \ /
  Last update: 2022-07-18 05:51    [W:0.070 / U:0.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site