aboutsummaryrefslogtreecommitdiff
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
parent33b022d873abc5255e22bf70687e5c0a260fb107 (diff)
downloadtoybox-1fb3ae7075ab9d198b757f7da5cc9c748abc3574.tar.gz
Various cleanups found by Tom Sparrow's static analysis.
-rw-r--r--lib/lib.c2
-rw-r--r--scripts/config2help.c3
-rw-r--r--scripts/mkflags.c1
-rw-r--r--toys/other/acpi.c7
-rw-r--r--toys/other/ifconfig.c7
-rw-r--r--toys/other/pmap.c4
6 files changed, 7 insertions, 17 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 6a9a0bdd..1126e11e 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -81,7 +81,7 @@ ssize_t writeall(int fd, void *buf, size_t len)
{
size_t count = 0;
while (count<len) {
- int i = write(fd, buf+count, len-count);
+ int i = write(fd, count+(char *)buf, len-count);
if (i<1) return i;
count += i;
}
diff --git a/scripts/config2help.c b/scripts/config2help.c
index 4b6c9dec..41b04c38 100644
--- a/scripts/config2help.c
+++ b/scripts/config2help.c
@@ -192,7 +192,6 @@ int dashlinesort(char **a, char **b)
int main(int argc, char *argv[])
{
FILE *fp;
- char *file;
if (argc != 3) {
fprintf(stderr, "usage: config2help Config.in .config\n");
@@ -392,4 +391,6 @@ int main(int argc, char *argv[])
}
sym = sym->next;
}
+
+ return 0;
}
diff --git a/scripts/mkflags.c b/scripts/mkflags.c
index 17067861..c350b198 100644
--- a/scripts/mkflags.c
+++ b/scripts/mkflags.c
@@ -72,7 +72,6 @@ struct flag *digest(char *string)
int main(int argc, char *argv[])
{
char command[256], flags[1023], allflags[1024];
- unsigned bit;
for (;;) {
struct flag *flist, *aflist, *offlist;
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;
}
diff --git a/toys/other/ifconfig.c b/toys/other/ifconfig.c
index 15d00d06..36529c95 100644
--- a/toys/other/ifconfig.c
+++ b/toys/other/ifconfig.c
@@ -56,13 +56,6 @@ GLOBALS(
int sockfd;
)
-//for ipv6 add/del
-struct ifreq_inet6 {
- struct in6_addr ifrinte6_addr;
- uint32_t ifrinet6_prefixlen;
- int ifrinet6_ifindex;
-};
-
// Convert hostname to binary address for AF_INET or AF_INET6
// return /prefix (or range max if none)
int get_addrinfo(char *host, sa_family_t af, void *addr)
diff --git a/toys/other/pmap.c b/toys/other/pmap.c
index 9ef1ade9..ab0b61cd 100644
--- a/toys/other/pmap.c
+++ b/toys/other/pmap.c
@@ -34,7 +34,7 @@ void pmap_main(void)
size_t len;
long long start, end, pss, tpss = 0, dirty, tdirty = 0, swap, tswap = 0,
total = 0;
- int count, xx = 0;
+ int xx = 0;
snprintf(toybuf, sizeof(toybuf), "/proc/%u/cmdline", pid);
line = readfile(toybuf, 0, 0);
@@ -57,7 +57,7 @@ void pmap_main(void)
// Loop through mappings
for (;;) {
- int off;
+ int off, count;
line = 0;
if (0 >= getline(&line, &len, fp)) break;