From 99e2a2e1569c898d39565a52ec60f8a167cf523e Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 13 Feb 2012 14:25:14 +0000 Subject: [PATCH] Add some FIXME around allocation code Remove also unreachable break.. --- daemons/lvmetad/lvmetad-core.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c index 8911af7e3..4f28a10f6 100644 --- a/daemons/lvmetad/lvmetad-core.c +++ b/daemons/lvmetad/lvmetad-core.c @@ -88,7 +88,7 @@ static struct dm_config_node *pvs(struct dm_config_node *vg) * TODO: This set_flag function is pretty generic and might make sense in a * library here or there. */ -static void set_flag(struct dm_config_tree *cft, struct dm_config_node *parent, +static int set_flag(struct dm_config_tree *cft, struct dm_config_node *parent, const char *field, const char *flag, int want) { struct dm_config_value *value = NULL, *pred = NULL; struct dm_config_node *node = dm_config_find_node(parent->child, field); @@ -103,10 +103,10 @@ static void set_flag(struct dm_config_tree *cft, struct dm_config_node *parent, } if (value && want) - return; + return 1; if (!value && !want) - return; + return 1; if (value && !want) { if (pred) { @@ -127,12 +127,17 @@ static void set_flag(struct dm_config_tree *cft, struct dm_config_node *parent, node->parent = parent; parent->child = node; } - new = dm_config_create_value(cft); + if (!(new = dm_config_create_value(cft))) { + /* FIXME error reporting */ + return 0; + } new->type = DM_CFG_STRING; new->v.str = flag; new->next = node->v; node->v = new; } + + return 1; } /* Either the "big" vgs lock, or a per-vg lock needs to be held before entering @@ -149,8 +154,11 @@ static int update_pv_status(lvmetad_state *s, while (pv) { const char *uuid = dm_config_find_str(pv->child, "id", NULL); int found = uuid ? (dm_hash_lookup(s->pvs, uuid) ? 1 : 0) : 0; - if (act) - set_flag(cft, pv, "status", "MISSING", !found); + if (act && + !set_flag(cft, pv, "status", "MISSING", !found)) { + complete = 0; + break; + } if (!found) { complete = 0; if (!act) { // optimisation @@ -215,7 +223,7 @@ static response vg_lookup(lvmetad_state *s, request r) res.error = 0; unlock_vg(s, uuid); - update_pv_status(s, cft, n, 1); + update_pv_status(s, cft, n, 1); /* FIXME error reporting */ return res; } @@ -615,7 +623,6 @@ int main(int argc, char *argv[]) case 'V': printf("lvmetad version 0\n"); exit(1); - break; } } -- 2.43.5