[PATCH] kernel.h: kill labs(), allow more types in abs()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Looking through include/linux/kernel.h, it appears to me that
labs() isn't used at all, and abs() returns only int.

Might it be beneficial to make abs() usable for a wider range of
types? At least that's what the below patch is intended to do.
Would that be generally a bad idea, or am I missing something?

Signed-off-by: Nicolas Kaiser <nikai@xxxxxxxxx>
---
--- a/include/linux/kernel.h	2005-11-20 11:48:57.000000000 +0100
+++ b/include/linux/kernel.h	2005-11-24 19:44:09.000000000 +0100
@@ -76,12 +76,7 @@ extern int cond_resched(void);
 #define might_sleep_if(cond) do { if (unlikely(cond)) might_sleep(); } while (0)
 
 #define abs(x) ({				\
-		int __x = (x);			\
-		(__x < 0) ? -__x : __x;		\
-	})
-
-#define labs(x) ({				\
-		long __x = (x);			\
+		typeof(x) __x = (x);		\
 		(__x < 0) ? -__x : __x;		\
 	})
 

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux