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

Revert "hints: rewrite function"

This reverts commit 70fb31b5d6.
This commit is contained in:
David Teigland 2019-11-14 12:15:05 -06:00
parent 31a862a6be
commit 7ea71a9eb9

View File

@ -586,29 +586,42 @@ static void _filter_to_str(struct cmd_context *cmd, int filter_cfg, char **strp)
char *str;
int pos = 0;
int len = 0;
int ret;
*strp = NULL;
if (!(cn = find_config_tree_array(cmd, filter_cfg, NULL)))
if (!(cn = find_config_tree_array(cmd, filter_cfg, NULL))) {
/* shouldn't happen because default is a|*| */
return;
for (cv = cn->v; cv; cv = cv->next)
if (cv->type == DM_CFG_STRING)
len += strlen(cv->v.str) + 1;
if (!len++ || !(str = malloc(len)))
return;
for (cv = cn->v; cv; cv = cv->next)
if (cv->type == DM_CFG_STRING) {
len = strlen(cv->v.str);
memcpy(str + pos, cv->v.str, len);
pos += len;
str[pos++] = 0;
}
str[pos] = 0;
for (cv = cn->v; cv; cv = cv->next) {
if (cv->type != DM_CFG_STRING)
continue;
len += (strlen(cv->v.str) + 1);
}
len++;
if (len == 1) {
/* shouldn't happen because default is a|*| */
return;
}
if (!(str = malloc(len)))
return;
memset(str, 0, len);
for (cv = cn->v; cv; cv = cv->next) {
if (cv->type != DM_CFG_STRING)
continue;
ret = snprintf(str + pos, len - pos, "%s", cv->v.str);
if (ret >= len - pos)
break;
pos += ret;
}
*strp = str;
}