From: drkhsh Date: Thu, 27 Oct 2022 22:15:21 +0000 (+0200) Subject: temp: Put sysctl into define to avoid line wraps X-Git-Url: https://git.atheridis.org/?a=commitdiff_plain;h=21327e0373189f9e9964f34fb5a15639d00575aa;p=suckless%2Fslstatus.git 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 #include + #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;