diff --git a/src/linux.cc b/src/linux.cc index 3af5fc7d..b20ca39c 100644 --- a/src/linux.cc +++ b/src/linux.cc @@ -1040,7 +1040,7 @@ static int open_sysfs_sensor(const char *dir, const char *dev, const char *type, snprintf(path, 255, "%s%s/%s%d_input", dir, dev, type, n); fd = open(path, O_RDONLY); if (fd < 0) { - CRIT_ERR(NULL, NULL, "can't open '%s': %s\nplease check your device or remove this " + NORM_ERR("can't open '%s': %s\nplease check your device or remove this " "var from "PACKAGE_NAME, path, strerror(errno)); } } @@ -1192,7 +1192,7 @@ void print_sysfs_sensor(struct text_object *obj, char *p, int p_max_size) double r; struct sysfs *sf = (struct sysfs *)obj->data.opaque; - if (!sf) + if (!sf || sf->fd < 0) return; r = get_sysfs_info(&sf->fd, sf->arg, @@ -1216,7 +1216,8 @@ void free_sysfs_sensor(struct text_object *obj) if (!sf) return; - close(sf->fd); + if(sf->fd >= 0) + close(sf->fd); free_and_zero(obj->data.opaque); }