selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Masatake YAMATO <yamato@redhat.com>, selinux@vger.kernel.org
Subject: Re: [Non-DoD Source] [PATCH 2/5] dispol: add an option for printing the command usage
Date: Wed, 9 Oct 2019 10:41:58 -0400	[thread overview]
Message-ID: <41f518a5-7e1b-7fa5-6338-c0341f48b671@tycho.nsa.gov> (raw)
In-Reply-To: <20191008064500.8651-4-yamato@redhat.com>

On 10/8/19 2:44 AM, Masatake YAMATO wrote:
> Signed-off-by: Masatake YAMATO <yamato@redhat.com>
> ---
>   checkpolicy/test/dispol.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/checkpolicy/test/dispol.c b/checkpolicy/test/dispol.c
> index 1d9556f4..37b22cf8 100644
> --- a/checkpolicy/test/dispol.c
> +++ b/checkpolicy/test/dispol.c
> @@ -39,7 +39,7 @@ static policydb_t policydb;
>   static __attribute__((__noreturn__)) void usage(const char *progname,
>   						int status)
>   {
> -	printf("usage:  %s binary_pol_file\n\n", progname);
> +	printf("usage:  %s [-h] binary_pol_file\n\n", progname);
>   	exit(status);
>   }
>   
> @@ -395,7 +395,11 @@ int main(int argc, char **argv)
>   	int state;
>   	struct policy_file pf;
>   
> -	if (argc != 2)
> +	if (argc <= 1)
> +		usage(argv[0], 1);
> +	else if (strcmp(argv[1], "-h") == 0)
> +		usage(argv[0], 0);
> +	else if (argc != 2)
>   		usage(argv[0], 1);

Use getopt(3) or getopt_long(3) please for option handling.

>   
>   	fd = open(argv[1], O_RDONLY);
> 


  reply	other threads:[~2019-10-09 14:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08  6:44 [PATCH 0/5] dispol: add batch execution mode Masatake YAMATO
2019-10-08  6:44 ` [PATCH 1/5] dispol: extend usage() to take error code as an argument Masatake YAMATO
2019-10-08  6:44 ` [PATCH 1/5] dispol: extend usage() to take exit status Masatake YAMATO
2019-10-08 14:03   ` Stephen Smalley
2019-10-08  6:44 ` [PATCH 2/5] dispol: add an option for printing the command usage Masatake YAMATO
2019-10-09 14:41   ` Stephen Smalley [this message]
2019-10-08  6:44 ` [PATCH 3/5] dispol: introduce a local variable representing the input file Masatake YAMATO
2019-10-08  6:44 ` [PATCH 4/5] dispol: introduce -b option to run commands in batch Masatake YAMATO
2019-10-08  6:45 ` [PATCH 5/5] dispol: add the list of commands for batch mode to help message Masatake YAMATO
2019-10-08 12:48 ` [PATCH 0/5] dispol: add batch execution mode Stephen Smalley
2019-10-08 14:31   ` Stephen Smalley
2019-10-17  7:12     ` Masatake YAMATO

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41f518a5-7e1b-7fa5-6338-c0341f48b671@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=selinux@vger.kernel.org \
    --cc=yamato@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).