X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/a4fe8c97414f07dd8b891e0d325dd2733195151d..80fc20d1d69b14f36ad9bb64d8af38481cbf1ff5:/components/battery.c diff --git a/components/battery.c b/components/battery.c index 49f43e6..807a7e6 100644 --- a/components/battery.c +++ b/components/battery.c @@ -59,13 +59,12 @@ fd = open("/dev/apm", O_RDONLY); if (fd < 0) { - fprintf(stderr, "open '/dev/apm': %s\n", strerror(errno)); + warn("open '/dev/apm':"); return NULL; } if (ioctl(fd, APM_IOC_GETPOWER, &apm_info) < 0) { - fprintf(stderr, "ioctl 'APM_IOC_GETPOWER': %s\n", - strerror(errno)); + warn("ioctl 'APM_IOC_GETPOWER':"); close(fd); return NULL; } @@ -90,13 +89,12 @@ fd = open("/dev/apm", O_RDONLY); if (fd < 0) { - fprintf(stderr, "open '/dev/apm': %s\n", strerror(errno)); + warn("open '/dev/apm':"); return NULL; } if (ioctl(fd, APM_IOC_GETPOWER, &apm_info) < 0) { - fprintf(stderr, "ioctl 'APM_IOC_GETPOWER': %s\n", - strerror(errno)); + warn("ioctl 'APM_IOC_GETPOWER':"); close(fd); return NULL; }