[sheepdog] [PATCH] dog: fix dog help messages output

Meng Lingkun menglingkun at cmss.chinamobile.com
Tue Mar 17 08:43:29 CET 2015


When a subcommand given by argv[3], always output help messages incorrectly.
For example: dog vdi object location|map|dump-inode, always output location's
help messages instead of map's or dump-inode's. So fix it.

Signed-off-by: Meng Lingkun <menglingkun at cmss.chinamobile.com>
---
 dog/common.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/dog/common.c b/dog/common.c
index 6ff1e19..0f73b2c 100644
--- a/dog/common.c
+++ b/dog/common.c
@@ -255,14 +255,13 @@ int do_generic_subcommand(struct subcommand *sub, int argc, char **argv)
 		exit(EXIT_USAGE);
 	}
 
-	subcmd_stack[++subcmd_depth] = sub;
-
 	for (i = 0; sub[i].name; i++) {
 		unsigned long flags;
 
 		if (strcmp(sub[i].name, argv[optind]))
 			continue;
 
+		subcmd_stack[++subcmd_depth] = &sub[i];
 		flags = sub[i].flags;
 
 		if (flags & CMD_NEED_NODELIST) {
-- 
1.7.1






More information about the sheepdog mailing list