_collapse_slashes() already goes through the whole string,
so just return now already known string length.
/*
* Get rid of extra slashes in the path string.
*/
-static void _collapse_slashes(char *str)
+static size_t _collapse_slashes(char *str)
{
+ char *start = str;
char *ptr;
int was_slash = 0;
*str++ = *ptr;
}
- *str = *ptr;
+ *str = 0;
+
+ return (str - start);
}
static int _insert_dir(const char *dir)
log_debug_devs("Dir path %s is too long", path);
return 0;
}
- _collapse_slashes(path);
- len = strlen(path);
+
+ len = _collapse_slashes(path);
if (len && path[len - 1] != '/')
path[len++] = '/';