summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrkhsh <me@drkhsh.at>2022-10-28 00:15:21 +0200
committerRafael Marçalo <raroma09@gmail.com>2022-10-28 22:22:28 +0100
commit0dfc423e83ea7e609ab63122d8a1e5b3ceed41b5 (patch)
treee08c2b8ded6542dbc9bde533566858db000e3788
parent8e4058fad2ce93a0c03e44fabd08ceb36c91baee (diff)
temp: Put sysctl into define to avoid line wraps
Long, wrapped, multi-line if statements suck to read. This fixes readability.
-rw-r--r--components/temperature.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/components/temperature.c b/components/temperature.c
index 7be5118..c61a574 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;