[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141118212523.GK26514@1wt.eu>
Date: Tue, 18 Nov 2014 22:25:23 +0100
From: Willy Tarreau <w@....eu>
To: Mariusz Gorski <marius.gorski@...il.com>
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 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
--
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