diff mbox series

[1/4] dispol: add --help option

Message ID 20230608015241.2454912-1-yamato@redhat.com (mailing list archive)
State Accepted
Commit f78eea5a3473
Headers show
Series [1/4] dispol: add --help option | expand

Commit Message

Masatake YAMATO June 8, 2023, 1:52 a.m. UTC
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
 checkpolicy/test/dispol.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

James Carter June 8, 2023, 2:21 p.m. UTC | #1
On Wed, Jun 7, 2023 at 9:59 PM Masatake YAMATO <yamato@redhat.com> wrote:
>
> Signed-off-by: Masatake YAMATO <yamato@redhat.com>

For these four patches:
Acked-by: James Carter <jwcart2@gmail.com>

Thanks,
Jim

> ---
>  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 b61f1b4b..50027e40 100644
> --- a/checkpolicy/test/dispol.c
> +++ b/checkpolicy/test/dispol.c
> @@ -38,7 +38,11 @@ static policydb_t policydb;
>
>  static __attribute__((__noreturn__)) void usage(const char *progname)
>  {
> -       printf("usage:  %s binary_pol_file\n\n", progname);
> +       puts("Usage:");
> +       printf(" %s [OPTIONS] binary_pol_file\n\n", progname);
> +       puts("Options:");
> +       puts(" -h, --help   print this help message");
> +       puts("\n");
>         exit(1);
>  }
>
> @@ -481,7 +485,7 @@ int main(int argc, char **argv)
>         int state;
>         struct policy_file pf;
>
> -       if (argc != 2)
> +       if (argc < 2 || strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)
>                 usage(argv[0]);
>
>         fd = open(argv[1], O_RDONLY);
> --
> 2.40.1
>
James Carter June 8, 2023, 7:52 p.m. UTC | #2
On Thu, Jun 8, 2023 at 10:21 AM James Carter <jwcart2@gmail.com> wrote:
>
> On Wed, Jun 7, 2023 at 9:59 PM Masatake YAMATO <yamato@redhat.com> wrote:
> >
> > Signed-off-by: Masatake YAMATO <yamato@redhat.com>
>
> For these four patches:
> Acked-by: James Carter <jwcart2@gmail.com>
>

These four patches have been merged.
Thanks,
Jim

> Thanks,
> Jim
>
> > ---
> >  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 b61f1b4b..50027e40 100644
> > --- a/checkpolicy/test/dispol.c
> > +++ b/checkpolicy/test/dispol.c
> > @@ -38,7 +38,11 @@ static policydb_t policydb;
> >
> >  static __attribute__((__noreturn__)) void usage(const char *progname)
> >  {
> > -       printf("usage:  %s binary_pol_file\n\n", progname);
> > +       puts("Usage:");
> > +       printf(" %s [OPTIONS] binary_pol_file\n\n", progname);
> > +       puts("Options:");
> > +       puts(" -h, --help   print this help message");
> > +       puts("\n");
> >         exit(1);
> >  }
> >
> > @@ -481,7 +485,7 @@ int main(int argc, char **argv)
> >         int state;
> >         struct policy_file pf;
> >
> > -       if (argc != 2)
> > +       if (argc < 2 || strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)
> >                 usage(argv[0]);
> >
> >         fd = open(argv[1], O_RDONLY);
> > --
> > 2.40.1
> >
diff mbox series

Patch

diff --git a/checkpolicy/test/dispol.c b/checkpolicy/test/dispol.c
index b61f1b4b..50027e40 100644
--- a/checkpolicy/test/dispol.c
+++ b/checkpolicy/test/dispol.c
@@ -38,7 +38,11 @@  static policydb_t policydb;
 
 static __attribute__((__noreturn__)) void usage(const char *progname)
 {
-	printf("usage:  %s binary_pol_file\n\n", progname);
+	puts("Usage:");
+	printf(" %s [OPTIONS] binary_pol_file\n\n", progname);
+	puts("Options:");
+	puts(" -h, --help   print this help message");
+	puts("\n");
 	exit(1);
 }
 
@@ -481,7 +485,7 @@  int main(int argc, char **argv)
 	int state;
 	struct policy_file pf;
 
-	if (argc != 2)
+	if (argc < 2 || strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)
 		usage(argv[0]);
 
 	fd = open(argv[1], O_RDONLY);