Messages in this thread | | | Subject | Re: [PATCH] thermal: Fix KELVIN_TO_CELSIUS macro | From | Joe Perches <> | Date | Sun, 23 Mar 2014 21:25:32 -0700 |
| |
On Sun, 2014-03-23 at 21:14 -0700, Guenter Roeck wrote: > 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.
Maybe it's better to use a statement expression to avoid multiple calculations of t
Maybe;
#define KELVIN_TO_CELSIUS(t) \ ({ \ long _t = (long)(t) - 2732; \ _t >= 0 ? (_t + 5) / 10 : (_t - 5) / 10; \ })
| |