linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <eduardo.valentin@ti.com>,
	Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH] thermal: Fix KELVIN_TO_CELSIUS macro
Date: Sun, 23 Mar 2014 21:14:56 -0700	[thread overview]
Message-ID: <1395634496-25040-1-git-send-email-linux@roeck-us.net> (raw)

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


             reply	other threads:[~2014-03-24  4:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-24  4:14 Guenter Roeck [this message]
2014-03-24  4:25 ` [PATCH] thermal: Fix KELVIN_TO_CELSIUS macro Joe Perches
2014-03-24  5:30   ` Guenter Roeck
2014-04-03  2:40     ` Zhang Rui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1395634496-25040-1-git-send-email-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=eduardo.valentin@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).