lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 31 Mar 2020 20:21:43 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Ivan Mikhaylov <i.mikhaylov@...ro.com>
Cc:     Jonathan Cameron <jic23@...nel.org>,
        Hartmut Knaack <knaack.h@....de>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Peter Meerwald-Stadler <pmeerw@...erw.net>,
        linux-iio <linux-iio@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        devicetree <devicetree@...r.kernel.org>,
        Mark Rutland <mark.rutland@....com>,
        Rob Herring <robh+dt@...nel.org>
Subject: Re: [PATCH v5 2/2] iio: proximity: Add driver support for vcnl3020
 proximity sensor

On Tue, Mar 31, 2020 at 7:56 PM Ivan Mikhaylov <i.mikhaylov@...ro.com> wrote:
> On Tue, 2020-03-31 at 14:00 +0300, Andy Shevchenko wrote:
> > > > Why not to use standard pattern, i.e.
> > > >
> > > >   if (rc)
> > > >     return rc;
> > > >   ...
> > > >   rc = regmap_write(...);
> > > >
> > > > ?
> > >
> > > Optional parameter. There exists a lot of ways to do it:
> >
> > I'm simple reading the code. And I believe the above I suggested is
> > cleaner equivalent.
> > Is it?
> >
> > > rc = device_property_read_u32(dev, "milliamp", &led_current);
> > > rc = regmap_write(regmap, VCNL_LED_CURRENT, (!rc) : led_current ? 0);
> >
> > This seems not equal to above.
>
> Yes, it is not equal. Error will be returned in case of non existent parameter
> in vcnl3020_init but parameter is optional. rc shouldn't be checked

Ah it makes sense.

> or should
> return 0 with your suggestion.
>
> rc = device_property_read_u32(...);
> if (rc)
>         return 0;
> rc = regmap_write(...);
> if (rc)
>         dev_err(...);
> return rc;

In case we would like to have more optional parameters above will be a burden.
Perhaps

static int get_and_apply_property_x(...)
{
  ...Above code...
}

...and in the function

rc = get_and_apply_property_x(...)
if (rc)
  return rc;

or if it's the last one,

return get_and_apply_property_x(...);

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ