From ebf5552754bdf0d4c04f45bef334799775776ad7 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Tue, 28 Feb 2012 17:46:47 +0000 Subject: [PATCH] Fix empty string warning logic in _find_config_str. (1.02.68) pvcreate gives WARNING: Ignoring unsupported value for metadata/pvmetadataignore. It was warning if there is no config file entry instead of only if the node exists but is empty. --- WHATS_NEW_DM | 1 + libdm/libdm-config.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 7de4785e2..49cc80e0f 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.73 - ==================================== + Fix empty string warning logic in _find_config_str. (1.02.68) Fix dm_task_set_name to properly resolve path to dm name (1.02.71). Add dm_strncpy() function as a faster strncpy() replacement. diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c index 97559171b..cd71f4e42 100644 --- a/libdm/libdm-config.c +++ b/libdm/libdm-config.c @@ -751,14 +751,16 @@ static const char *_find_config_str(const void *start, node_lookup_fn find_fn, { const struct dm_config_node *n = find_fn(start, path); - /* Empty strings are ignored */ - if ((n && n->v && n->v->type == DM_CFG_STRING) && - (allow_empty || (*n->v->v.str))) { - log_very_verbose("Setting %s to %s", path, n->v->v.str); - return n->v->v.str; - } else if (n && (!n->v || (n->v->type != DM_CFG_STRING) || - (!allow_empty && fail))) - log_warn("WARNING: Ignoring unsupported value for %s.", path); + /* Empty strings are ignored if allow_empty is set */ + if (n && n->v) { + if ((n->v->type == DM_CFG_STRING) && + (allow_empty || (*n->v->v.str))) { + log_very_verbose("Setting %s to %s", path, n->v->v.str); + return n->v->v.str; + } + if ((n->v->type != DM_CFG_STRING) || (!allow_empty && fail)) + log_warn("WARNING: Ignoring unsupported value for %s.", path); + } if (fail) log_very_verbose("%s not found in config: defaulting to %s", -- 2.43.5