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

config: use find_config_tree_array for all arrays

Use find_config_tree_array for all config arrays. Also, add
INTERNAL_ERROR in case there should have been at least default
value defined for a setting but it was not returned for some
reason (either config_settings.h misconfiguration or other config
tree error printed by functions called by find_config_tree_array).
This commit is contained in:
Peter Rajnoha 2015-07-15 10:52:23 +02:00
parent 7e728fe1a1
commit 34a4109946
2 changed files with 9 additions and 9 deletions

View File

@ -245,8 +245,10 @@ static int _parse_debug_classes(struct cmd_context *cmd)
const struct dm_config_value *cv; const struct dm_config_value *cv;
int debug_classes = 0; int debug_classes = 0;
if (!(cn = find_config_tree_array(cmd, log_debug_classes_CFG, NULL))) if (!(cn = find_config_tree_array(cmd, log_debug_classes_CFG, NULL))) {
log_error(INTERNAL_ERROR "Unable to find configuration for log/debug_classes.");
return -1; return -1;
}
for (cv = cn->v; cv; cv = cv->next) { for (cv = cn->v; cv; cv = cv->next) {
if (cv->type != DM_CFG_STRING) { if (cv->type != DM_CFG_STRING) {
@ -686,7 +688,7 @@ static int _process_config(struct cmd_context *cmd)
DEFAULT_RUN_DIR "/lvmetad.socket"); DEFAULT_RUN_DIR "/lvmetad.socket");
*/ */
lvmetad_set_socket(lvmetad_socket); lvmetad_set_socket(lvmetad_socket);
cn = find_config_tree_node(cmd, devices_global_filter_CFG, NULL); cn = find_config_tree_array(cmd, devices_global_filter_CFG, NULL);
lvmetad_set_token(cn ? cn->v : NULL); lvmetad_set_token(cn ? cn->v : NULL);
if (find_config_tree_int(cmd, global_locking_type_CFG, NULL) == 3 && if (find_config_tree_int(cmd, global_locking_type_CFG, NULL) == 3 &&
@ -1015,11 +1017,9 @@ static int _init_dev_cache(struct cmd_context *cmd)
init_obtain_device_list_from_udev(device_list_from_udev); init_obtain_device_list_from_udev(device_list_from_udev);
if (!(cn = find_config_tree_node(cmd, devices_scan_CFG, NULL))) { if (!(cn = find_config_tree_array(cmd, devices_scan_CFG, NULL))) {
log_verbose("device/scan not in config file, " log_error(INTERNAL_ERROR "Unable to find configuration for devices/scan.");
"using defaults."); return_0;
if (!(cn = find_config_tree_array(cmd, devices_scan_CFG, NULL)))
return_0;
} }
for (cv = cn->v; cv; cv = cv->next) { for (cv = cn->v; cv; cv = cv->next) {
@ -1232,7 +1232,7 @@ static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache
} }
/* filter component 1 */ /* filter component 1 */
if ((cn = find_config_tree_node(cmd, devices_filter_CFG, NULL))) { if ((cn = find_config_tree_array(cmd, devices_filter_CFG, NULL))) {
if (!(filter_components[1] = regex_filter_create(cn->v))) if (!(filter_components[1] = regex_filter_create(cn->v)))
goto_bad; goto_bad;
/* we have two filter components - create composite filter */ /* we have two filter components - create composite filter */

View File

@ -347,7 +347,7 @@ static int _memlock_maps(struct cmd_context *cmd, lvmlock_t lock, size_t *mstats
} }
line = _maps_buffer; line = _maps_buffer;
cn = find_config_tree_node(cmd, activation_mlock_filter_CFG, NULL); cn = find_config_tree_array(cmd, activation_mlock_filter_CFG, NULL);
while ((line_end = strchr(line, '\n'))) { while ((line_end = strchr(line, '\n'))) {
*line_end = '\0'; /* remove \n */ *line_end = '\0'; /* remove \n */