changeset 632:6cafecf34728

Trivial cleanups.
author Rob Landley <rob@landley.net>
date Wed, 18 Jul 2012 21:10:57 -0500
parents 7c1a825f5afb
children 98bde84a888c
files toys/lsmod.c toys/modinfo.c
diffstat 2 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/toys/lsmod.c	Wed Jul 18 20:28:19 2012 -0500
+++ b/toys/lsmod.c	Wed Jul 18 21:10:57 2012 -0500
@@ -22,7 +22,8 @@
 
 void lsmod_main(void)
 {
-	FILE * file = xfopen("/proc/modules", "r");
+	char *modfile = "/proc/modules";
+	FILE * file = xfopen(modfile, "r");
 
 	xprintf("%-23s Size  Used by\n", "Module");
 
@@ -35,7 +36,7 @@
 			if (users[len] == ',' || users[len] == '-')
 				users[len] = 0;
 			xprintf("%-19s %8s  %s %s\n", name, size, refcnt, users);
-		} else perror_exit("unrecognized input");
+		} else perror_exit("bad %s", modfile);
 	}
 	fclose(file);
 }
--- a/toys/modinfo.c	Wed Jul 18 20:28:19 2012 -0500
+++ b/toys/modinfo.c	Wed Jul 18 21:10:57 2012 -0500
@@ -86,8 +86,7 @@
         char **s;
         for (s = toys.optargs; *s; s++) {
             int len = strlen(*s);
-            if (strncmp(*s, new->name, len) == 0 &&
-                    strcmp(&new->name[len], ".ko") == 0)
+            if (!strncmp(*s, new->name, len) && !strcmp(new->name+len, ".ko"))
                 modinfo_file(new);
         }
     }
@@ -98,8 +97,7 @@
 void modinfo_main(void)
 {
     struct utsname uts;
-    if (uname(&uts) < 0)
-        perror_exit("unable to determine uname");
+    if (uname(&uts) < 0) perror_exit("bad uname");
     sprintf(toybuf, "/lib/modules/%s", uts.release);
     dirtree_read(toybuf, check_module);
 }