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-next>] [day] [month] [year] [list]
Date:	Thu, 19 Apr 2007 11:23:39 +0200
From:	Jiri Bohac <jbohac@...e.cz>
To:	akpm@...l.org
Cc:	linux-kernel@...r.kernel.org
Subject: [RFC][PATCH] fix abs() macro to work with types wider than int

Hi,

is there any reason to use an explicit int instead of a typeof in
the abs() macro? The current implementation will return bogus
results when used with longs.

How about changing the int to a typeof like this?:





Fix the abs() macro to work with wider types than int.

Signed-off-by: Jiri Bohac <jbohac@...e.cz>

--- linux-2.6.21-rc5.orig/include/linux/kernel.h
+++ linux-2.6.21-rc5/include/linux/kernel.h
@@ -89,7 +89,7 @@ extern int cond_resched(void);
 #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
 
 #define abs(x) ({				\
-		int __x = (x);			\
+		typeof(x) __x = (x);			\
 		(__x < 0) ? -__x : __x;		\
 	})
 



-- 
Jiri Bohac <jbohac@...e.cz>
SUSE Labs, SUSE CZ

-
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