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, 29 Jan 2019 17:24:04 -0700
From:   Jerry Hoemann <jerry.hoemann@....com>
To:     Matti Vaittinen <matti.vaittinen@...rohmeurope.com>
Cc:     Guenter Roeck <linux@...ck-us.net>, mazziesaccount@...il.com,
        heikki.haikola@...rohmeurope.com, mikko.mutanen@...rohmeurope.com,
        lee.jones@...aro.org, robh+dt@...nel.org, mark.rutland@....com,
        broonie@...nel.org, gregkh@...uxfoundation.org, rafael@...nel.org,
        mturquette@...libre.com, sboyd@...nel.org,
        linus.walleij@...aro.org, bgolaszewski@...libre.com,
        sre@...nel.org, lgirdwood@...il.com, a.zummo@...ertech.it,
        alexandre.belloni@...tlin.com, wim@...ux-watchdog.org,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-clk@...r.kernel.org, linux-gpio@...r.kernel.org,
        linux-pm@...r.kernel.org, linux-rtc@...r.kernel.org,
        linux-watchdog@...r.kernel.org
Subject: Re: [RFC PATCH v2 08/10] rtc: bd70528: Initial support for ROHM
 bd70528 RTC

On Tue, Jan 29, 2019 at 09:01:03AM +0200, Matti Vaittinen wrote:
> On Mon, Jan 28, 2019 at 01:26:56PM -0700, Jerry Hoemann wrote:
> > On Sat, Jan 26, 2019 at 08:30:24AM -0800, Guenter Roeck wrote:
> > > On 1/25/19 3:05 AM, Matti Vaittinen wrote:
> > > > +static int bd70528_set_wake(struct bd70528 *bd70528,
> > > > +			    int enable, int *old_state)
> > > > +{
> > > > +	int ret;
> > > > +	unsigned int ctrl_reg;
> > > > +
> > > > +	ret = regmap_read(bd70528->chip.regmap, BD70528_REG_WAKE_EN, &ctrl_reg);
> > > > +	if (ret)
> > > > +		return ret;
> > > > +
> > > > +	if (old_state) {
> > > > +		if (ctrl_reg & BD70528_MASK_WAKE_EN)
> > > > +			*old_state |= BD70528_WAKE_STATE_BIT;
> > > > +		else
> > > > +			*old_state &= ~BD70528_WAKE_STATE_BIT;
> > > > +
> > > > +		if ((!enable) == (!(*old_state & BD70528_WAKE_STATE_BIT)))
> > > > +			return 0;
> > > 
> > > I think
> > > 		if (enable == !!(*old_state & BD70528_WAKE_STATE_BIT))
> > > would be much better readable. Even if not, there are way too many ()
> > > in the above conditional.
> > > 
> > 
> > The substitution is not equivalent to original.  I think you mean:
> > 
> >  		if (!!enable == !!(*old_state & BD70528_WAKE_STATE_BIT))
> 
> Thanks Jerry! Good catch! I originally wanted that all non-zero values
> of 'enable' would be 'true'. So maybe I just use the original approach
> but get rid of extra parenthesis which were pointed out by Guenter.
> 
> 		if (!enable == !(*old_state & BD70528_WAKE_STATE_BIT))
> should do it just fine, right?
> 

The use of "!!" to turn an int into one of two Boolean values (0 | 1)
is used extensively in Linux and as such might make the intent of
the code a bit clearer which I take as checking to see the states
match.

But, I will defer to you and Guenter on the question.

-- 

-----------------------------------------------------------------------------
Jerry Hoemann                  Software Engineer   Hewlett Packard Enterprise
-----------------------------------------------------------------------------

Powered by blists - more mailing lists