Skip to contentSkip to conversation

master - cleanup: add cmd_context reference to struct cft_check_handle

PATCH Peter Rajnoha 1 participant 1 message Mar 19, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=000e81a999a456a6db2de1aef70a147b00fb7491
Commit:        000e81a999a456a6db2de1aef70a147b00fb7491
Parent:        b6eb2ac10ab509a74f83b9333ff195b63d64d8ef
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Wed Mar 19 08:45:05 2014 +0100
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Wed Mar 19 08:45:05 2014 +0100

cleanup: add cmd_context reference to struct cft_check_handle

So we have all things needed to do a configuration check packaged in one handle. It makes function calls inside a bit more readable.

---
 lib/commands/toolcontext.c |    3 +-
 lib/config/config.c        |   56 +++++++++++++++++++++----------------------
 lib/config/config.h        |    3 +-
 tools/dumpconfig.c         |    5 ++-
 4 files changed, 34 insertions(+), 33 deletions(-)
lib/commands/toolcontext.c +2 -1
index e620884..899666c 100644
@@ -269,8 +269,9 @@ static int _check_config(struct cmd_context *cmd)
 	}
 
 	cmd->cft_check_handle->cft = cmd->cft;
+	cmd->cft_check_handle->cmd = cmd;
 
-	if (!config_def_check(cmd, cmd->cft_check_handle) &&
+	if (!config_def_check(cmd->cft_check_handle) &&
 	    find_config_tree_bool(cmd, config_abort_on_errors_CFG, NULL)) {
 		log_error("LVM configuration invalid.");
 		return 0;
lib/config/config.c +27 -29

180 lines not on this page · raw message

lib/config/config.h +2 -1
index 5bfa345..e5bcab8 100644
@@ -165,6 +165,7 @@ int load_pending_profiles(struct cmd_context *cmd);
 
 /* configuration check handle for each instance of the validation check */
 struct cft_check_handle {
+	struct cmd_context *cmd;	/* command context */
 	struct dm_config_tree *cft;	/* the tree for which the check is done */
 	config_source_t source;		/* configuration source */
 	unsigned force_check:1;		/* force check even if disabled by config/checks setting */
@@ -174,7 +175,7 @@ struct cft_check_handle {
 };
 
 int config_def_get_path(char *buf, size_t buf_size, int id);
-int config_def_check(struct cmd_context *cmd, struct cft_check_handle *handle);
+int config_def_check(struct cft_check_handle *handle);
 
 int override_config_tree_from_string(struct cmd_context *cmd, const char *config_settings);
 int override_config_tree_from_profile(struct cmd_context *cmd, struct profile *profile);
tools/dumpconfig.c +3 -2
index d9aebd9..7404462 100644
@@ -47,6 +47,7 @@ static struct cft_check_handle *_get_cft_check_handle(struct cmd_context *cmd, s
 			log_error("Configuration check handle allocation failed.");
 			return NULL;
 		}
+		handle->cmd = cmd;
 		handle->cft = cft;
 		if (cft == cmd->cft)
 			cmd->cft_check_handle = handle;
@@ -67,7 +68,7 @@ static int _do_def_check(struct cmd_context *cmd, struct dm_config_tree *cft,
 	handle->skip_if_checked = 1;
 	handle->suppress_messages = 1;
 
-	config_def_check(cmd, handle);
+	config_def_check(handle);
 	*cft_check_handle = handle;
 
 	return 1;
@@ -155,7 +156,7 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
 		cft_check_handle->skip_if_checked = 1;
 		cft_check_handle->suppress_messages = 0;
 
-		if (config_def_check(cmd, cft_check_handle)) {
+		if (config_def_check(cft_check_handle)) {
 			log_print("LVM configuration valid.");
 			goto out;
 		} else {