[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VeS+3-N9rV3CfTLHKKD_pzTHrz4Lnv5XsEbd22CoCJeKw@mail.gmail.com>
Date: Mon, 11 Apr 2022 19:49:20 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: "Rafael J. Wysocki" <rafael@...nel.org>
Cc: "Rafael J. Wysocki" <rjw@...ysocki.net>,
Linux PM <linux-pm@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Ulf Hansson <ulf.hansson@...aro.org>,
Alan Stern <stern@...land.harvard.edu>
Subject: Re: [PATCH v1] PM: runtime: Avoid device usage count underflows
On Mon, Apr 11, 2022 at 6:17 PM Rafael J. Wysocki <rafael@...nel.org> wrote:
> On Mon, Apr 11, 2022 at 5:09 PM Andy Shevchenko
> <andy.shevchenko@...il.com> wrote:
> > On Wed, Apr 6, 2022 at 11:49 PM Rafael J. Wysocki <rjw@...ysocki.net> wrote:
...
> > > + retval = rpm_drop_usage_count(dev);
> > > + if (retval > 0) {
> > > trace_rpm_usage_rcuidle(dev, rpmflags);
> > > return 0;
> > > + } else if (retval < 0) {
> > > + return retval;
> > > }
> >
> > Can be written in a form
> >
> > if (retval < 0)
> > return retval;
> > if (retval > 0) {
> > trace_rpm_usage_rcuidle(dev, rpmflags);
> > return 0;
> > }
> >
>
> I know.
>
> And why would it be better?
Depends on the perception:
a) less characters to parse (no 'else');
b) checking for errors first, which seems more or less standard pattern.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists