libfstools: optimize building directory string for glob
authorRafał Miłecki <rafal@milecki.pl>
Fri, 5 Jan 2018 14:24:30 +0000 (15:24 +0100)
committerJohn Crispin <john@phrozen.org>
Sun, 7 Jan 2018 12:01:21 +0000 (13:01 +0100)
glob should handle paths like /foo/bar//* so we probably don't need this
extra check & code.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
libfstools/overlay.c

index e610b8d36e7342190352c463eac6cd87ec87abb3..0187a5512d83fcd6feec2d5a0cc59321428e317d 100644 (file)
@@ -86,10 +86,7 @@ foreachdir(const char *dir, int (*cb)(const char*))
                globdirlen = len;
        }
 
-       if (dir[dirlen - 1] == '/')
-               sprintf(globdir, "%s*", dir);
-       else
-               sprintf(globdir, "%s/*", dir);
+       sprintf(globdir, "%s/*", dir);
 
        if (!glob(globdir, GLOB_NOESCAPE | GLOB_MARK | GLOB_ONLYDIR, NULL, &gl))
                for (j = 0; j < gl.gl_pathc; j++) {