[lvm-devel] [PATCH 11/11] Move initialization of cmd->fmt into init_formats().

Dave Wysochanski dwysocha at redhat.com
Wed Dec 10 18:11:01 UTC 2008


init_formats() sets up the command formats, and currently sets cmd->fmt_backup
but does not set cmd->fmt to a default value.  This seems incorrect so we
set it to cmd->default_settings.fmt before returning.

The call we remove here may set cmd->fmt based on a command line setting.
But it is safe to remove this, because the only caller of init_lvm() that
cares about the cmdline override is the cmdline tools (clvmd does not care),
called from lvm2_main().  After lvm2_main() calls init_lvm(), it later calls
lvm_run_command().  In lvm_run_command(), we have a call to _apply_settings(),
which has the identical assignment of cmd->fmt that this patch removes.

Signed-off-by: Dave Wysochanski <dwysocha at redhat.com>
---
 lib/commands/toolcontext.c |    1 +
 tools/lvmcmdline.c         |    3 ---
 2 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 186a816..e66972c 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -787,6 +787,7 @@ static int _init_formats(struct cmd_context *cmd)
 			return 1;
 		}
 	}
+	cmd->fmt = cmd->default_settings.fmt;
 
 	log_error("_init_formats: Default format (%s) not found", format);
 	return 0;
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 162be2d..5e02057 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1093,9 +1093,6 @@ struct cmd_context *init_lvm(unsigned is_static)
 
 	init_full_scan_done(0);
 
-	cmd->fmt = arg_ptr_value(cmd, metadatatype_ARG,
-				 cmd->current_settings.fmt);
-
 	return cmd;
 }
 
-- 
1.5.5.1




More information about the lvm-devel mailing list