temp: Put sysctl into define to avoid line wraps
authordrkhsh <me@drkhsh.at>
Thu, 27 Oct 2022 22:15:21 +0000 (00:15 +0200)
committerdrkhsh <me@drkhsh.at>
Thu, 27 Oct 2022 23:02:58 +0000 (01:02 +0200)
Long, wrapped, multi-line if statements suck to read.
This fixes readability.

components/temperature.c

index 306a09f16524f0d579b48a3bfa47ad29a1cc0185..01d21b97203ae89c81b39bedb3ce5a8cd3b12000 100644 (file)
@@ -53,6 +53,8 @@
        #include <stdlib.h>
        #include <sys/sysctl.h>
 
+       #define ACPI_TEMP "hw.acpi.thermal.%s.temperature"
+
        const char *
        temp(const char *zone)
        {
@@ -61,8 +63,8 @@
                size_t len;
 
                len = sizeof(temp);
-               snprintf(buf, sizeof(buf), "hw.acpi.thermal.%s.temperature", zone);
-               if (sysctlbyname(buf, &temp, &len, NULL, 0) == -1
+               snprintf(buf, sizeof(buf), ACPI_TEMP, zone);
+               if (sysctlbyname(buf, &temp, &len, NULL, 0) < 0
                                || !len)
                        return NULL;