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

gcc-fanalyzer: rewrite _fetch_string

Slightly more optimal code, that is less confusing analyzers.
This commit is contained in:
Zdenek Kabelac 2021-09-20 13:51:20 +02:00
parent 30b188857c
commit 909401226c

View File

@ -709,15 +709,11 @@ int dm_event_unregister_handler(const struct dm_event_handler *dmevh)
static char *_fetch_string(char **src, const int delimiter)
{
char *p, *ret;
size_t len = (p = strchr(*src, delimiter)) ?
p - *src : strlen(*src);
if ((p = strchr(*src, delimiter)))
*p = 0;
if ((ret = strdup(*src)))
*src += strlen(ret) + 1;
if (p)
*p = delimiter;
if ((ret = strndup(*src, len)))
*src += len + 1;
return ret;
}