diff --git a/modules/battery.c b/modules/battery.c index 121d616..9e2a27b 100644 --- a/modules/battery.c +++ b/modules/battery.c @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -159,23 +160,25 @@ initialize(struct private *m) { int fd = openat(base_dir_fd, "manufacturer", O_RDONLY); if (fd == -1) { - LOG_ERRNO("/sys/class/power_supply/%s/manufacturer", m->battery); - goto err; + LOG_WARN("/sys/class/power_supply/%s/manufacturer: %s", + m->battery, strerror(errno)); + m->manufacturer = NULL; + } else { + m->manufacturer = strdup(readline_from_fd(fd)); + close(fd); } - - m->manufacturer = strdup(readline_from_fd(fd)); - close(fd); } { int fd = openat(base_dir_fd, "model_name", O_RDONLY); if (fd == -1) { - LOG_ERRNO("/sys/class/power_supply/%s/model_name", m->battery); - goto err; + LOG_WARN("/sys/class/power_supply/%s/model_name: %s", + m->battery, strerror(errno)); + m->model = NULL; + } else { + m->model = strdup(readline_from_fd(fd)); + close(fd); } - - m->model = strdup(readline_from_fd(fd)); - close(fd); } {