Message ID | 20191008064500.8651-4-yamato@redhat.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | dispol: add batch execution mode | expand |
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); >
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); fd = open(argv[1], O_RDONLY);
Signed-off-by: Masatake YAMATO <yamato@redhat.com> --- checkpolicy/test/dispol.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)