diff options
Diffstat (limited to 'src/fan/fan.c')
-rw-r--r-- | src/fan/fan.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/fan/fan.c b/src/fan/fan.c index adc49cc..a9cf754 100644 --- a/src/fan/fan.c +++ b/src/fan/fan.c @@ -23,18 +23,14 @@ #include <string.h> #include <libgen.h> #include <errno.h> -#include <stdbool.h> #include <sensors/sensors.h> #include <sensors/error.h> #include "fan.h" -#include "globals.h" const char *provider_name = "fan"; const ConfigEntry *provider_config_defaults = NULL; -#define MAX_CHIP_NAME_LENGTH 200 - //* constants ***************************************************************** static bool MODULE_INITIALIZED = false; @@ -98,8 +94,8 @@ static cim_fan_error_t libsensors2cim_fan_error(int err) { static const char * sprintf_chip_name(sensors_chip_name const *name) { /** @return NULL on error, cstring otherwise, it needs to be freed */ int charcnt; - char buf[MAX_CHIP_NAME_LENGTH]; - if ((charcnt = sensors_snprintf_chip_name(buf, MAX_CHIP_NAME_LENGTH, name)) < 0) + char buf[BUFLEN]; + if ((charcnt = sensors_snprintf_chip_name(buf, BUFLEN, name)) < 0) return NULL; return strndup(buf, charcnt); } @@ -110,17 +106,17 @@ static cim_fan_error_t reload_config_file(char const * fp) { * @return 0 on success */ FILE *config_file = NULL; int err; - char errbuf[STRERROR_BUF_LEN]; + char errbuf[BUFLEN]; if (fp) { if (!(config_file = fopen(fp, "r"))) { - error("Cound not open config file \"%s\": %s\n", - fp, strerror_r(errno, errbuf, sizeof(errbuf))); + lmi_error("Cound not open config file \"%s\": %s\n", + fp, strerror_r(errno, errbuf, sizeof(errbuf))); } } err = sensors_init(config_file); if (err) { - error("sensors_init: %s\n", sensors_strerror(err)); + lmi_error("sensors_init: %s\n", sensors_strerror(err)); if (config_file) fclose(config_file); }else { if (config_file) fclose(config_file); @@ -251,12 +247,12 @@ static struct cim_fan * _load_fan_data( sensors_chip_name const *chip return NULL; } if (!(f->chip_name = sprintf_chip_name(chip))) { - error("could not get chip name\n"); + lmi_error("could not get chip name\n"); goto lab_err_free_fan; } f->sys_path = chip->path; if (!(f->name = sensors_get_label(chip, feature))) { - error("could not get fan name for chip: %s\n", + lmi_error("could not get fan name for chip: %s\n", f->chip_name); goto lab_err_chip_name; } |