From: Karel Zak Date: Mon, 30 Jan 2012 12:19:14 +0000 (+0100) Subject: whereis: move token assignment into loop syntax X-Git-Tag: v2.21-rc2~80 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=48a5ed6306191eeea0474a98f232738e2f270e4d;p=thirdparty%2Futil-linux.git whereis: move token assignment into loop syntax Reported-by: Davidlohr Bueso Signed-off-by: Karel Zak --- diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c index 925cc93900..17bb2d4784 100644 --- a/misc-utils/whereis.c +++ b/misc-utils/whereis.c @@ -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))