[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJZ5v0h-hB918OxUjHQCypyR8JKNEV8FxR7LRYaraoq+Mazfhw@mail.gmail.com>
Date: Mon, 11 Apr 2022 20:07:25 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
"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:53 PM Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
>
> 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:
Well, exactly.
> a) less characters to parse (no 'else');
But to me, with the "else" it is clear that the conditionals are
related to each other which is not so clear otherwise at first sight.
YMMV
> b) checking for errors first, which seems more or less standard pattern.
So the checks can be reversed no problem, but this is such a minor point ,,,
Powered by blists - more mailing lists