mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] objtool: Print top level commands on incorrect usage
@ 2017-10-13  8:21 Kamalesh Babulal
  2017-10-13 16:38 ` Josh Poimboeuf
  0 siblings, 1 reply; 3+ messages in thread
From: Kamalesh Babulal @ 2017-10-13  8:21 UTC (permalink / raw)
  To: Josh Poimboeuf; +Cc: Kamalesh Babulal, linux-kernel, Ingo Molnar

Maintain the consistency with objtool subcommands, by
printing cmd_usage() of top level commands, along with
the error. When incorrect option/command is passed to
objtool. Also change the exit code to 129, like other
objtool subcommands.

After the patch:
$ ./objtool -j
Unknown option: -j

 usage: objtool COMMAND [ARGS]

 Commands:
   check   Perform stack metadata validation on an object file
   orc     Generate in-place ORC unwind tables for an object file

$ echo $?
129

Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
---
 tools/objtool/objtool.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/objtool/objtool.c b/tools/objtool/objtool.c
index 31e0f91..07f3299 100644
--- a/tools/objtool/objtool.c
+++ b/tools/objtool/objtool.c
@@ -70,7 +70,7 @@ static void cmd_usage(void)
 
 	printf("\n");
 
-	exit(1);
+	exit(129);
 }
 
 static void handle_options(int *argc, const char ***argv)
@@ -86,9 +86,7 @@ static void handle_options(int *argc, const char ***argv)
 			break;
 		} else {
 			fprintf(stderr, "Unknown option: %s\n", cmd);
-			fprintf(stderr, "\n Usage: %s\n",
-				objtool_usage_string);
-			exit(1);
+			cmd_usage();
 		}
 
 		(*argv)++;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] objtool: Print top level commands on incorrect usage
  2017-10-13  8:21 [PATCH] objtool: Print top level commands on incorrect usage Kamalesh Babulal
@ 2017-10-13 16:38 ` Josh Poimboeuf
  2017-10-14 14:38   ` Kamalesh Babulal
  0 siblings, 1 reply; 3+ messages in thread
From: Josh Poimboeuf @ 2017-10-13 16:38 UTC (permalink / raw)
  To: Kamalesh Babulal; +Cc: linux-kernel, Ingo Molnar

On Fri, Oct 13, 2017 at 01:51:12PM +0530, Kamalesh Babulal wrote:
> Maintain the consistency with objtool subcommands, by
> printing cmd_usage() of top level commands, along with
> the error. When incorrect option/command is passed to
> objtool. Also change the exit code to 129, like other
> objtool subcommands.
> 
> After the patch:
> $ ./objtool -j
> Unknown option: -j
> 
>  usage: objtool COMMAND [ARGS]
> 
>  Commands:
>    check   Perform stack metadata validation on an object file
>    orc     Generate in-place ORC unwind tables for an object file
> 
> $ echo $?
> 129
> 
> Cc: Ingo Molnar <mingo@kernel.org>
> Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
> ---
>  tools/objtool/objtool.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/objtool/objtool.c b/tools/objtool/objtool.c
> index 31e0f91..07f3299 100644
> --- a/tools/objtool/objtool.c
> +++ b/tools/objtool/objtool.c
> @@ -70,7 +70,7 @@ static void cmd_usage(void)
>  
>  	printf("\n");
>  
> -	exit(1);
> +	exit(129);

For consistency with the rest of the code, this should be -1 instead of
129 (though the end result is the same).

-- 
Josh

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] objtool: Print top level commands on incorrect usage
  2017-10-13 16:38 ` Josh Poimboeuf
@ 2017-10-14 14:38   ` Kamalesh Babulal
  0 siblings, 0 replies; 3+ messages in thread
From: Kamalesh Babulal @ 2017-10-14 14:38 UTC (permalink / raw)
  To: Josh Poimboeuf; +Cc: linux-kernel, Ingo Molnar

On Friday 13 October 2017 10:08 PM, Josh Poimboeuf wrote:
[...]
>> Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
>> ---
>>  tools/objtool/objtool.c | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/tools/objtool/objtool.c b/tools/objtool/objtool.c
>> index 31e0f91..07f3299 100644
>> --- a/tools/objtool/objtool.c
>> +++ b/tools/objtool/objtool.c
>> @@ -70,7 +70,7 @@ static void cmd_usage(void)
>>
>>  	printf("\n");
>>
>> -	exit(1);
>> +	exit(129);
>
> For consistency with the rest of the code, this should be -1 instead of
> 129 (though the end result is the same).
>

Thanks for the review. exit(129) is returned by command line parser
when the usage is incorrect, except for cmd_usage(), where the exit
code 1. I will re-send the patch with the better commit message.


-- 
cheers,
Kamalesh.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-14 14:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-13  8:21 [PATCH] objtool: Print top level commands on incorrect usage Kamalesh Babulal
2017-10-13 16:38 ` Josh Poimboeuf
2017-10-14 14:38   ` Kamalesh Babulal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®