]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
whereis: move token assignment into loop syntax
authorKarel Zak <kzak@redhat.com>
Mon, 30 Jan 2012 12:19:14 +0000 (13:19 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 30 Jan 2012 12:19:14 +0000 (13:19 +0100)
Reported-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/whereis.c

index 925cc93900d60b2bb93c5d624ca526b71f508e97..17bb2d478449f32c084dd779dc9d5f2096953ca9 100644 (file)
@@ -260,7 +260,7 @@ static int inpath(const char *str)
 
 static void fillpath(void)
 {
-       char *key=NULL, *tmp=NULL, *tok=NULL, *pathcp, *path = getenv("PATH");
+       char *key=NULL, *tok=NULL, *pathcp, *path = getenv("PATH");
        int i = 0;
 
 
@@ -268,10 +268,8 @@ static void fillpath(void)
                return;
        pathcp = xstrdup(path);
 
-       for (tmp = pathcp; ; tmp = NULL) {
-               tok = strtok_r(tmp, ":", &key);
-               if (!tok)
-                       break;
+       for (tok = strtok_r(pathcp, ":", &key); tok;
+            tok = strtok_r(NULL, ":", &key)) {
 
                /* make sure we don't repeat the search path */
                if (inpath(tok))