changeset 1202:4f080cdb2f6e draft

Various cleanups found by Tom Sparrow's static analysis.
author Rob Landley <rob@landley.net>
date Sun, 16 Feb 2014 11:09:23 -0600
parents 9adf66c7dd4e
children 2a68f22aa286
files lib/lib.c scripts/config2help.c scripts/mkflags.c toys/other/acpi.c toys/other/ifconfig.c toys/other/pmap.c
diffstat 6 files changed, 7 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/lib/lib.c	Thu Feb 13 06:45:35 2014 -0600
+++ b/lib/lib.c	Sun Feb 16 11:09:23 2014 -0600
@@ -81,7 +81,7 @@
 {
   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;
   }
--- a/scripts/config2help.c	Thu Feb 13 06:45:35 2014 -0600
+++ b/scripts/config2help.c	Sun Feb 16 11:09:23 2014 -0600
@@ -192,7 +192,6 @@
 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 @@
     }
     sym = sym->next;
   }
+
+  return 0;
 }
--- a/scripts/mkflags.c	Thu Feb 13 06:45:35 2014 -0600
+++ b/scripts/mkflags.c	Sun Feb 16 11:09:23 2014 -0600
@@ -72,7 +72,6 @@
 int main(int argc, char *argv[])
 {
   char command[256], flags[1023], allflags[1024];
-  unsigned bit;
 
   for (;;) {
     struct flag *flist, *aflist, *offlist;
--- a/toys/other/acpi.c	Thu Feb 13 06:45:35 2014 -0600
+++ b/toys/other/acpi.c	Sun Feb 16 11:09:23 2014 -0600
@@ -40,7 +40,7 @@
 
 int acpi_callback(struct dirtree *tree)
 {
-  int dfd;
+  int dfd, fd, len, on;
 
   errno = 0;
 
@@ -50,8 +50,6 @@
     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 @@
         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;
 }
 
--- a/toys/other/ifconfig.c	Thu Feb 13 06:45:35 2014 -0600
+++ b/toys/other/ifconfig.c	Sun Feb 16 11:09:23 2014 -0600
@@ -56,13 +56,6 @@
   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)
--- a/toys/other/pmap.c	Thu Feb 13 06:45:35 2014 -0600
+++ b/toys/other/pmap.c	Sun Feb 16 11:09:23 2014 -0600
@@ -34,7 +34,7 @@
     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 @@
 
     // Loop through mappings
     for (;;) {
-      int off;
+      int off, count;
 
       line = 0;
       if (0 >= getline(&line, &len, fp)) break;