Long, wrapped, multi-line if statements suck to read.
This fixes readability.
#include <stdlib.h>
#include <sys/sysctl.h>
+ #define ACPI_TEMP "hw.acpi.thermal.%s.temperature"
+
const char *
temp(const char *zone)
{
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;