OSDN Git Service

ACPI: thermal: Replace ternary operator with min_t()
authorJiangshan Yi <yijiangshan@kylinos.cn>
Tue, 28 Mar 2023 03:16:29 +0000 (11:16 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 30 Mar 2023 17:09:49 +0000 (19:09 +0200)
Modify the code in accordance with the coccicheck warning:

drivers/acpi/thermal.c:422: WARNING opportunity for min().

min_t() macro is defined in include/linux/minmax.h. It avoids multiple
evaluations of the arguments when non-constant and performs strict
type-checking.

Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
[ rjw: Changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/thermal.c

index 0b4b844..179f411 100644 (file)
@@ -419,10 +419,9 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
                                         * the next higher trip point
                                         */
                                        tz->trips.active[i-1].temperature =
-                                               (tz->trips.active[i-2].temperature <
-                                               celsius_to_deci_kelvin(act) ?
-                                               tz->trips.active[i-2].temperature :
-                                               celsius_to_deci_kelvin(act));
+                                               min_t(unsigned long,
+                                                     tz->trips.active[i-2].temperature,
+                                                     celsius_to_deci_kelvin(act));
 
                                break;
                        } else {