lkml.org 
[lkml]   [2014]   [Mar]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] thermal: Fix KELVIN_TO_CELSIUS macro
Date
It is always a good idea to use paranthesis around macro parameters
to avoid undesired side effects.

In this specific case, KELVIN_TO_CELSIUS() is used in
drivers/platform/x86/asus-wmi.c with parameter "value & 0xFFFF",
which due to operator evaluation order causes more or less random
results.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
include/linux/thermal.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index f7e11c7..02488c9 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -41,8 +41,8 @@
#define THERMAL_NO_LIMIT THERMAL_CSTATE_INVALID

/* Unit conversion macros */
-#define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732 >= 0) ? \
- ((long)t-2732+5)/10 : ((long)t-2732-5)/10)
+#define KELVIN_TO_CELSIUS(t) (long)(((long)(t)-2732 >= 0) ? \
+ ((long)(t)-2732+5)/10 : ((long)(t)-2732-5)/10)
#define CELSIUS_TO_KELVIN(t) ((t)*10+2732)

/* Adding event notification support elements */
--
1.7.9.7


\
 
 \ /
  Last update: 2014-03-24 05:41    [W:0.070 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site