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: <1416344174-9155-9-git-send-email-marius.gorski@gmail.com>
Date:	Tue, 18 Nov 2014 21:56:13 +0100
From:	Mariusz Gorski <marius.gorski@...il.com>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Willy Tarreau <w@....eu>
Cc:	devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: [PATCH 8/9] staging: panel: Remove more magic number comparison

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;
-	if (lcd_bwidth > -1)
+	if (IS_SET(lcd_bwidth))
 		lcd.bwidth = lcd_bwidth;
-	if (lcd_hwidth > -1)
+	if (IS_SET(lcd_hwidth))
 		lcd.hwidth = lcd_hwidth;
-	if (lcd_charset > -1)
+	if (IS_SET(lcd_charset))
 		lcd.charset = lcd_charset;
-	if (lcd_proto > -1)
+	if (IS_SET(lcd_proto))
 		lcd.proto = lcd_proto;
 	if (lcd_e_pin != PIN_NOT_SET)
 		lcd.pins.e = lcd_e_pin;
@@ -2306,16 +2307,16 @@ static int __init panel_init_module(void)
 	 * Overwrite selection with module param values (both keypad and lcd),
 	 * where the deprecated params have lower prio.
 	 */
-	if (keypad_enabled > -1)
+	if (IS_SET(keypad_enabled))
 		selected_keypad_type = keypad_enabled;
-	if (keypad_type > -1)
+	if (IS_SET(keypad_type))
 		selected_keypad_type = keypad_type;
 
 	keypad.enabled = (selected_keypad_type > 0);
 
-	if (lcd_enabled > -1)
+	if (IS_SET(lcd_enabled))
 		selected_lcd_type = lcd_enabled;
-	if (lcd_type > -1)
+	if (IS_SET(lcd_type))
 		selected_lcd_type = lcd_type;
 
 	lcd.enabled = (selected_lcd_type > 0);
-- 
2.1.3

--
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