From 8530ba751dff760f8dd1ae87ade07a8b6f2e9fe2 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Sun, 23 Nov 2014 23:06:23 -0600 Subject: [PATCH] wmacpi: Fix -Wunused-result compiler warnings. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In particular, libacpi.c: In function ‘power_init’: libacpi.c:339:5: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result] fread(buf, 4096, 1, acpi); ^ libacpi.c: In function ‘procfs_get_power_status’: libacpi.c:434:5: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result] fgets(buf, 1024, file); ^ --- wmacpi/libacpi.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wmacpi/libacpi.c b/wmacpi/libacpi.c index 14d98d4..7590b1b 100644 --- a/wmacpi/libacpi.c +++ b/wmacpi/libacpi.c @@ -324,6 +324,7 @@ int power_init(global_t *globals) char buf[4096]; int acpi_ver = 0; int retval; + size_t buflen; unsigned int version_offset = 0; if (!(acpi = fopen("/sys/module/acpi/parameters/acpica_version", "r"))) { @@ -336,7 +337,11 @@ int power_init(global_t *globals) } /* okay, now see if we got the right version */ - fread(buf, 4096, 1, acpi); + buflen = fread(buf, 4096, 1, acpi); + if (buflen != 4096 && ferror(acpi)) { + pfatal("Could not read file\n"); + return 1; + } acpi_ver = strtol(buf + version_offset, NULL, 10); pinfo("ACPI version detected: %d\n", acpi_ver); if (acpi_ver < 20020214) { @@ -431,7 +436,10 @@ static power_state_t procfs_get_power_status(global_t *globals) return PS_ERR; } - fgets(buf, 1024, file); + if (!fgets(buf, 1024, file)) { + pfatal("Could not read file\n"); + return PS_ERR; + } fclose(file); val = get_value(buf); if ((strncmp(val, "on-line", 7)) == 0) -- 2.11.4.GIT