summaryrefslogtreecommitdiffstats
path: root/src/fan/fan.c
diff options
context:
space:
mode:
authorJan Synacek <jsynacek@redhat.com>2014-04-29 08:33:13 +0200
committerJan Synacek <jsynacek@redhat.com>2014-04-30 15:54:14 +0200
commit55f63d29f5d2b4e82979d71386df58394e87ef5a (patch)
tree34227f5696df9b3a85c5999d2fd48f50be82681f /src/fan/fan.c
parentdab89c6afb2a2b339ebadea3d47e841cd749b5ef (diff)
downloadopenlmi-providers-55f63d29f5d2b4e82979d71386df58394e87ef5a.tar.gz
openlmi-providers-55f63d29f5d2b4e82979d71386df58394e87ef5a.tar.xz
openlmi-providers-55f63d29f5d2b4e82979d71386df58394e87ef5a.zip
libopenlmi: reorganize and gather
Make naming consistent. Gather common functionality into one library and try to use it across all providers. Introduce libtool-style versioning for libraries.
Diffstat (limited to 'src/fan/fan.c')
-rw-r--r--src/fan/fan.c20
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;
}