1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

validate_lvname: early exit

If the LV name does not any have '_' chr,
there is no point trying to call 'strstr()' to look for "_suffix".
Also we can search from _.
This commit is contained in:
Zdenek Kabelac 2024-10-31 13:53:20 +01:00
parent ae8ba49142
commit 7bf404db3b

View File

@ -172,6 +172,9 @@ static const char *_lvname_has_reserved_component_string(const char *lvname)
}; };
unsigned i; unsigned i;
if (!(lvname = strchr(lvname, '_')))
return NULL;
for (i = 0; i < DM_ARRAY_SIZE(_strings); ++i) for (i = 0; i < DM_ARRAY_SIZE(_strings); ++i)
if (strstr(lvname, _strings[i])) if (strstr(lvname, _strings[i]))
return _strings[i]; return _strings[i];
@ -189,6 +192,9 @@ static const char *_lvname_has_reserved_string(const char *lvname)
unsigned i; unsigned i;
const char *cs; const char *cs;
if (!(lvname = strchr(lvname, '_')))
return NULL;
if ((cs = _lvname_has_reserved_component_string(lvname))) if ((cs = _lvname_has_reserved_component_string(lvname)))
return cs; return cs;