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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141118215053.GC10306@firebird>
Date:	Tue, 18 Nov 2014 22:50:54 +0100
From:	Mariusz Gorski <marius.gorski@...il.com>
To:	Willy Tarreau <w@....eu>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 8/9] staging: panel: Remove more magic number comparison

On Tue, Nov 18, 2014 at 10:25:23PM +0100, Willy Tarreau wrote:
> On Tue, Nov 18, 2014 at 09:56:13PM +0100, Mariusz Gorski wrote:
> > Use a macro instead of magic number comparison for checking
> > whether a module param value has been set.
> > 
> > Signed-off-by: Mariusz Gorski <marius.gorski@...il.com>
> > ---
> >  drivers/staging/panel/panel.c | 21 +++++++++++----------
> >  1 file changed, 11 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
> > index ee48bca..268ad2e 100644
> > --- a/drivers/staging/panel/panel.c
> > +++ b/drivers/staging/panel/panel.c
> > @@ -136,6 +136,7 @@
> >  #define NOT_SET			-1
> >  
> >  #define IS_NOT_SET(x)	(x == NOT_SET)
> > +#define IS_SET(x)		(x > NOT_SET)
> >  
> >  /* macros to simplify use of the parallel port */
> >  #define r_ctr(x)        (parport_read_control((x)->port))
> > @@ -1496,17 +1497,17 @@ static void lcd_init(void)
> >  	}
> >  
> >  	/* Overwrite with module params set on loading */
> > -	if (lcd_height > -1)
> > +	if (IS_SET(lcd_height))
> >  		lcd.height = lcd_height;
> > -	if (lcd_width > -1)
> > +	if (IS_SET(lcd_width))
> >  		lcd.width = lcd_width;
> 
> (...)
> 
> Same as for the other patch, better open-code the test for readability :
> 
> -	if (lcd_height > -1)
> +	if (lcd_height != NOT_SET)
>  		lcd.height = lcd_height;
> 
> Note that we take the freedom to change the operator since we only want
> to check equality and not sign in practice.
> 
> Willy
>

Good point, will apply :)

Thanks,
Mariusz
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ