diff options
author | Pablo Barciela <[email protected]> | 2017-12-29 16:56:34 +0100 |
---|---|---|
committer | Pablo Barciela <[email protected]> | 2017-12-29 16:56:34 +0100 |
commit | d0ec08fae4bdc55a31c5533bca298a44e9b9cb39 (patch) | |
tree | 1f8a4900b2da5e40359166aad4d259c683d742c1 /battstat | |
parent | 341cd453ca93a6842f2535a827dab88c95257cb8 (diff) | |
download | mate-applets-d0ec08fae4bdc55a31c5533bca298a44e9b9cb39.tar.bz2 mate-applets-d0ec08fae4bdc55a31c5533bca298a44e9b9cb39.tar.xz |
Fix build warnings: ignoring return value of ‘fgets’,
declared with attribute warn_unused_result
Diffstat (limited to 'battstat')
-rw-r--r-- | battstat/apmlib/apmlib.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/battstat/apmlib/apmlib.c b/battstat/apmlib/apmlib.c index 41c8fdf7..0e9946cd 100644 --- a/battstat/apmlib/apmlib.c +++ b/battstat/apmlib/apmlib.c @@ -59,7 +59,10 @@ int apm_read(apm_info * i) if (!(str = fopen(APM_PROC, "r"))) return 1; - fgets(buffer, sizeof(buffer) - 1, str); + + if (fgets(buffer, sizeof(buffer) - 1, str) == NULL) + printf("fgets error\n"); + buffer[sizeof(buffer) - 1] = '\0'; /* Should check for other driver versions; driver 1.9 (and some @@ -95,12 +98,19 @@ int apm_read(apm_info * i) sscanf(buffer, "BIOS version: %d.%d", &i->apm_version_major, &i->apm_version_minor); - fgets(buffer, sizeof(buffer) - 1, str); + + if (fgets(buffer, sizeof(buffer) - 1, str) == NULL) + printf("fgets error\n"); + sscanf(buffer, "Flags: 0x%02x", &i->apm_flags); if (i->apm_flags & APM_32_BIT_SUPPORT) { - fgets(buffer, sizeof(buffer) - 1, str); - fgets(buffer, sizeof(buffer) - 1, str); + if (fgets(buffer, sizeof(buffer) - 1, str) == NULL) + printf("fgets error\n"); + + if (fgets(buffer, sizeof(buffer) - 1, str) == NULL) + printf("fgets error\n"); + if (buffer[0] != 'P') { if (!strncmp(buffer + 4, "off line", 8)) @@ -110,7 +120,9 @@ int apm_read(apm_info * i) else if (!strncmp(buffer + 4, "on back", 7)) i->ac_line_status = 2; - fgets(buffer, sizeof(buffer) - 1, str); + if (fgets(buffer, sizeof(buffer) - 1, str) == NULL) + printf("fgets error\n"); + if (!strncmp(buffer + 16, "high", 4)) i->battery_status = 0; else if (!strncmp(buffer + 16, "low", 3)) @@ -120,15 +132,21 @@ int apm_read(apm_info * i) else if (!strncmp(buffer + 16, "charg", 5)) i->battery_status = 3; - fgets(buffer, sizeof(buffer) - 1, str); + if (fgets(buffer, sizeof(buffer) - 1, str) == NULL) + printf("fgets error\n"); + if (strncmp(buffer + 14, "unknown", 7)) i->battery_percentage = atoi(buffer + 14); if (i->apm_version_major >= 1 && i->apm_version_minor >= 1) { - fgets(buffer, sizeof(buffer) - 1, str); + if (fgets(buffer, sizeof(buffer) - 1, str) == NULL) + printf("fgets error\n"); + sscanf(buffer, "Battery flag: 0x%02x", &i->battery_flags); - fgets(buffer, sizeof(buffer) - 1, str); + if (fgets(buffer, sizeof(buffer) - 1, str) == NULL) + printf("fgets error\n"); + if (strncmp(buffer + 14, "unknown", 7)) i->battery_time = atoi(buffer + 14); } |