1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00

config: require dm_config_create_value for dm_config_node's value

If we were defining a section (which is a node without a value) and
the value was created automatically on dm_config_create_node call,
we were wasting resources as the next step after creating the config
node itself was assigning NULL for the node's value.

The dm_config_node_create + dm_config_create_value sequence should be
used instead for settings and dm_config_node_create alone for sections.

The majority of the code already used the correct sequence. Though
with dm_config_node_create fn creating the value as well, the pool
memory was being trashed this way.

This patch removes the node value initialization on dm_config_create_node
fn call and keeps it for the direct dm_config_create_value fn call.
This commit is contained in:
Peter Rajnoha 2012-08-27 14:19:30 +02:00
parent 2a70e98b05
commit 847e2856a2
3 changed files with 10 additions and 7 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.77 - Version 1.02.77 -
================================= =================================
Don't create value for dm_config_node and require dm_config_create_value call.
Check for existing new_name for dmsetup rename. Check for existing new_name for dmsetup rename.
Fix memory leak in dmsetup _get_split_name() error path. Fix memory leak in dmsetup _get_split_name() error path.

View File

@ -520,12 +520,19 @@ static response vg_lookup(lvmetad_state *s, request r)
if (!(res.cft->root = n = dm_config_create_node(res.cft, "response"))) if (!(res.cft->root = n = dm_config_create_node(res.cft, "response")))
goto bad; goto bad;
if (!(n->v = dm_config_create_value(cft)))
goto bad;
n->parent = res.cft->root; n->parent = res.cft->root;
n->v->type = DM_CFG_STRING; n->v->type = DM_CFG_STRING;
n->v->v.str = "OK"; n->v->v.str = "OK";
if (!(n = n->sib = dm_config_create_node(res.cft, "name"))) if (!(n = n->sib = dm_config_create_node(res.cft, "name")))
goto bad; goto bad;
if (!(n->v = dm_config_create_value(res.cft)))
goto bad;
n->parent = res.cft->root; n->parent = res.cft->root;
n->v->type = DM_CFG_STRING; n->v->type = DM_CFG_STRING;
n->v->v.str = name; n->v->v.str = name;

View File

@ -1169,14 +1169,9 @@ struct dm_config_node *dm_config_create_node(struct dm_config_tree *cft, const c
log_error("Failed to create config node's key."); log_error("Failed to create config node's key.");
return NULL; return NULL;
} }
if (!(cn->v = _create_value(cft->mem))) {
log_error("Failed to create config node's value.");
return NULL;
}
cn->parent = NULL; cn->parent = NULL;
cn->v->type = DM_CFG_INT; cn->v = NULL;
cn->v->v.i = 0;
cn->v->next = NULL;
return cn; return cn;
} }