From ed96a9feb4b17cdc08249a21d003c7fa2c51cc11 Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Fri, 19 Dec 2008 14:43:02 +0000 Subject: [PATCH] Fix incorrect return value in help function. --- WHATS_NEW | 1 + tools/lvmcmdline.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 4a5ea16fc..1d9882aa3 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.44 - ==================================== + Fix incorrect return value in help function. Fix vgrename using UUID in case there are VGs with the same name. Fix segfault when invalid field given in reporting commands. Refactor init_lvm() for lvmcmdline and clvmd. diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index f4a19e5f4..0b12750ce 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -568,14 +568,17 @@ static void _short_usage(const char *name) log_error("Run `%s --help' for more information.", name); } -static void _usage(const char *name) +static int _usage(const char *name) { struct command *com = _find_command(name); - if (!com) - return; + if (!com) { + log_print("%s: no such command.", name); + return 0; + } log_print("%s: %s\n\n%s", com->name, com->desc, com->usage); + return 1; } /* @@ -852,15 +855,18 @@ static void _display_help(void) int help(struct cmd_context *cmd __attribute((unused)), int argc, char **argv) { + int ret = ECMD_PROCESSED; + if (!argc) _display_help(); else { int i; for (i = 0; i < argc; i++) - _usage(argv[i]); + if (!_usage(argv[i])) + ret = EINVALID_CMD_LINE; } - return 0; + return ret; } static int _override_settings(struct cmd_context *cmd)