mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
dev-cache: collapsing slashes counts string size
_collapse_slashes() already goes through the whole string, so just return now already known string length.
This commit is contained in:
parent
caa0e08738
commit
d8e639ecba
@ -854,8 +854,9 @@ static int _insert_dev(const char *path, dev_t d)
|
|||||||
/*
|
/*
|
||||||
* Get rid of extra slashes in the path string.
|
* 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;
|
char *ptr;
|
||||||
int was_slash = 0;
|
int was_slash = 0;
|
||||||
|
|
||||||
@ -870,7 +871,9 @@ static void _collapse_slashes(char *str)
|
|||||||
*str++ = *ptr;
|
*str++ = *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
*str = *ptr;
|
*str = 0;
|
||||||
|
|
||||||
|
return (str - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _insert_dir(const char *dir)
|
static int _insert_dir(const char *dir)
|
||||||
@ -884,8 +887,8 @@ static int _insert_dir(const char *dir)
|
|||||||
log_debug_devs("Dir path %s is too long", path);
|
log_debug_devs("Dir path %s is too long", path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
_collapse_slashes(path);
|
|
||||||
len = strlen(path);
|
len = _collapse_slashes(path);
|
||||||
if (len && path[len - 1] != '/')
|
if (len && path[len - 1] != '/')
|
||||||
path[len++] = '/';
|
path[len++] = '/';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user