[lvm-devel] master - commands: initialize commands[] once

David Teigland teigland at fedoraproject.org
Thu Feb 16 20:03:41 UTC 2017


Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1cb95fa5a050c5056d882ef9cbb01ce8040df019
Commit:        1cb95fa5a050c5056d882ef9cbb01ce8040df019
Parent:        15f51bc42113494bfb49fbc0d6a1913f68fb80a8
Author:        David Teigland <teigland at redhat.com>
AuthorDate:    Thu Feb 16 13:59:52 2017 -0600
Committer:     David Teigland <teigland at redhat.com>
CommitterDate: Thu Feb 16 13:59:52 2017 -0600

commands: initialize commands[] once

When using liblvm2cmd, a process can do multiple
init/exit calls, i.e.

lvm2_init(); lvm2_run(); lvm2_exit();
lvm2_init(); lvm2_run(); lvm2_exit();
...

define_commands() needs to set up the global commands[]
definitions only the first time.
---
 tools/lvmcmdline.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index ed32f1c..e599ded 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1130,6 +1130,10 @@ void lvm_register_commands(char *name)
 {
 	int i;
 
+	/* already initialized */
+	if (_cmdline.commands)
+		return;
+
 	memset(&commands, 0, sizeof(commands));
 
 	/*




More information about the lvm-devel mailing list