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]
Message-ID: <20200424091806.GA2647@amd>
Date:   Fri, 24 Apr 2020 11:18:06 +0200
From:   Pavel Machek <pavel@....cz>
To:     Lubomir Rintel <lkundrak@...sk>
Cc:     Dan Murphy <dmurphy@...com>,
        Jacek Anaszewski <jacek.anaszewski@...il.com>,
        linux-kernel@...r.kernel.org, linux-leds@...r.kernel.org
Subject: Re: [PATCH v3] leds: ariel: Add driver for status LEDs on Dell Wyse
 3020

Hi!

> > > +enum ec_index {
> > > +	EC_BLUE_LED	= 0x01,
> > > +	EC_AMBER_LED	= 0x02,
> > 
> > Defining the value after the 0x0 is unnecessary as enums are incremental
> > only the first value needs to be defined if the following values are in
> > numerical order
> 
> I believe this improves readability, especially in case such as this
> where the actual numeric values matter.
> 
> > Can these also be #defined instead of an enum?  Not requesting them to be
> > just wondering about the design decision here.
> 
> It seems to be that this is what enums are for and theres is no need to
> get the preprocessor involved?
> 
> I guess this might be a personal preference, but it seems to me that
> both enums and preprocessor defines are used across the code base.

enums are okay.

> > > +	if (regmap_read(led->ec_ram, led->ec_index, &led_status))
> > > +		return LED_OFF;
> > > +
> > > +	if (led_status == EC_LED_STILL)
> > > +		return LED_FULL;
> > > +	else
> > else is not needed here
> > > +		return LED_OFF;
> > > +}
> 
> Yes, but should it be dropped? To me it seems like explicit else is
> better than implicit fallthrough. It is better when it's obvious that
> the LED_OFF is returned precisely only when the status is not
> EC_LED_STILL and that nothing ever happens afterwards -- and the
> compiler/linter will warn when anything unreachable is added afterwards.
> 
> Not that it matters too much here. It's just that I've done this
> deliberately because it seems more readable to be and would prefer to
> leave it that way unless you really really care about that.

Both versions are okay. I may have tiny bit of preference for deleting
the else, but...

Thank you,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ