[Pkg-wmaker-commits] [wmacpi] 37/105: wmacpi: Fix -Wunused-result compiler warnings.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Tue Aug 18 01:13:43 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmacpi.
commit a4eabfa252ea462a02d3f60f5e7699625ff4737a
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date: Sun Nov 23 23:06:23 2014 -0600
wmacpi: Fix -Wunused-result compiler warnings.
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);
^
---
libacpi.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/libacpi.c b/libacpi.c
index 14d98d4..7590b1b 100644
--- a/libacpi.c
+++ b/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)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmacpi.git
More information about the Pkg-wmaker-commits
mailing list