temp: Put sysctl into define to avoid line wraps - slstatus - status monitor
HTML git clone git://git.suckless.org/slstatus
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 21327e0373189f9e9964f34fb5a15639d00575aa
DIR parent 69b2487650782f135db76078c4a7fb841cb936ac
HTML Author: drkhsh <me@drkhsh.at>
Date: Fri, 28 Oct 2022 00:15:21 +0200
temp: Put sysctl into define to avoid line wraps
Long, wrapped, multi-line if statements suck to read.
This fixes readability.
Diffstat:
M components/temperature.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
DIR diff --git 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;