aboutsummaryrefslogtreecommitdiff
path: root/toys/other/acpi.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-02-16 11:09:23 -0600
committerRob Landley <rob@landley.net>2014-02-16 11:09:23 -0600
commit1fb3ae7075ab9d198b757f7da5cc9c748abc3574 (patch)
tree883cbdd98ecc483f6a5a948b1709e878de5bbdca /toys/other/acpi.c
parent33b022d873abc5255e22bf70687e5c0a260fb107 (diff)
downloadtoybox-1fb3ae7075ab9d198b757f7da5cc9c748abc3574.tar.gz
Various cleanups found by Tom Sparrow's static analysis.
Diffstat (limited to 'toys/other/acpi.c')
-rw-r--r--toys/other/acpi.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/toys/other/acpi.c b/toys/other/acpi.c
index 11d3ee63..1b31f313 100644
--- a/toys/other/acpi.c
+++ b/toys/other/acpi.c
@@ -40,7 +40,7 @@ int read_int_at(int dirfd, char *name)
int acpi_callback(struct dirtree *tree)
{
- int dfd;
+ int dfd, fd, len, on;
errno = 0;
@@ -50,8 +50,6 @@ int acpi_callback(struct dirtree *tree)
return DIRTREE_RECURSE | DIRTREE_SYMFOLLOW;
if (0 <= (dfd = open(dirtree_path(tree, NULL), O_RDONLY))) {
- int fd, len;
-
if ((fd = openat(dfd, "type", O_RDONLY)) < 0) goto done;
len = readall(fd, toybuf, sizeof(toybuf));
close(fd);
@@ -71,14 +69,13 @@ int acpi_callback(struct dirtree *tree)
if (cap >= 0) printf("Battery %d: %d%%\n", TT.bat++, cap);
}
} else if (toys.optflags & FLAG_a) {
- int on;
-
if ((on = read_int_at(dfd, "online")) >= 0)
printf("Adapter %d: %s-line\n", TT.ac++, (on ? "on" : "off"));
}
done:
close(dfd);
}
+
return 0;
}