commit 21327e0373189f9e9964f34fb5a15639d00575aa
Author:     drkhsh <[email protected]>
AuthorDate: Fri Oct 28 00:15:21 2022 +0200
Commit:     drkhsh <[email protected]>
CommitDate: Fri Oct 28 01:02:58 2022 +0200

    temp: Put sysctl into define to avoid line wraps
    
    Long, wrapped, multi-line if statements suck to read.
    This fixes readability.

diff --git a/components/temperature.c b/components/temperature.c
index 306a09f..01d21b9 100644
--- a/components/temperature.c
+++ b/components/temperature.c
@@ -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;
 

Reply via email to