Re: [PATCH] Global replace exit(0) with more readable exit(EXIT_SUCCESS)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



merged: https://github.com/SELinuxProject/selinux/pull/148

On Fri, May 10, 2019 at 2:00 PM William Roberts
<bill.c.roberts@xxxxxxxxx> wrote:
>
> On Fri, May 10, 2019 at 12:03 PM Jokke Hämäläinen
> <jokke.hamalainen@xxxxxxxxxxxx> wrote:
> >
> >
> >
> > ---
> >  libselinux/utils/avcstat.c         | 4 ++--
> >  libselinux/utils/compute_av.c      | 2 +-
> >  libselinux/utils/compute_create.c  | 2 +-
> >  libselinux/utils/compute_member.c  | 2 +-
> >  libselinux/utils/compute_relabel.c | 2 +-
> >  libselinux/utils/compute_user.c    | 4 ++--
> >  libselinux/utils/getfilecon.c      | 2 +-
> >  libselinux/utils/getpidcon.c       | 2 +-
> >  libselinux/utils/getseuser.c       | 2 +-
> >  libselinux/utils/policyvers.c      | 2 +-
> >  libselinux/utils/setfilecon.c      | 2 +-
> >  11 files changed, 13 insertions(+), 13 deletions(-)
> >
> > diff --git a/libselinux/utils/avcstat.c b/libselinux/utils/avcstat.c
> > index 884a10bf..da239287 100644
> > --- a/libselinux/utils/avcstat.c
> > +++ b/libselinux/utils/avcstat.c
> > @@ -116,7 +116,7 @@ int main(int argc, char **argv)
> >                 case 'h':
> >                 case '-':
> >                         usage();
> > -                       exit(0);
> > +                       exit(EXIT_SUCCESS);
>
> I wonder why this is exit success (as well as other spots)? Wouldn't
> something triggering usage be a fail unless they
> asked for usage()? Is that what - is doing ($ avcstat ----)? The man
> page doesn't mention it. Dan what was your thoughts here?
> I'm assuming you wrote it based on the man page and it seems to be
> included from Josh's initial import from SVN.
>
> >                 default:
> >                         usage();
> >                         die("unrecognized parameter '%c'", i);
> > @@ -133,7 +133,7 @@ int main(int argc, char **argv)
> >                 }
> >                 if (n == 0) {
> >                         usage();
> > -                       exit(0);
> > +                       exit(EXIT_SUCCESS);
> >                 }
> >                 interval = n;
> >         }
> > diff --git a/libselinux/utils/compute_av.c b/libselinux/utils/compute_av.c
> > index 574fa6ed..df4a77e8 100644
> > --- a/libselinux/utils/compute_av.c
> > +++ b/libselinux/utils/compute_av.c
> > @@ -51,5 +51,5 @@ int main(int argc, char **argv)
> >                 printf("\n");
> >         }
> >
> > -       exit(0);
> > +       exit(EXIT_SUCCESS);
> >  }
> > diff --git a/libselinux/utils/compute_create.c b/libselinux/utils/compute_create.c
> > index 4abc29fb..449ccd90 100644
> > --- a/libselinux/utils/compute_create.c
> > +++ b/libselinux/utils/compute_create.c
> > @@ -32,5 +32,5 @@ int main(int argc, char **argv)
> >
> >         printf("%s\n", buf);
> >         freecon(buf);
> > -       exit(0);
> > +       exit(EXIT_SUCCESS);
> >  }
> > diff --git a/libselinux/utils/compute_member.c b/libselinux/utils/compute_member.c
> > index 14edd451..c6dad19e 100644
> > --- a/libselinux/utils/compute_member.c
> > +++ b/libselinux/utils/compute_member.c
> > @@ -32,5 +32,5 @@ int main(int argc, char **argv)
> >
> >         printf("%s\n", buf);
> >         freecon(buf);
> > -       exit(0);
> > +       exit(EXIT_SUCCESS);
> >  }
> > diff --git a/libselinux/utils/compute_relabel.c b/libselinux/utils/compute_relabel.c
> > index 970750e8..85c760bc 100644
> > --- a/libselinux/utils/compute_relabel.c
> > +++ b/libselinux/utils/compute_relabel.c
> > @@ -32,5 +32,5 @@ int main(int argc, char **argv)
> >
> >         printf("%s\n", buf);
> >         freecon(buf);
> > -       exit(0);
> > +       exit(EXIT_SUCCESS);
> >  }
> > diff --git a/libselinux/utils/compute_user.c b/libselinux/utils/compute_user.c
> > index cae62b26..86d00a6e 100644
> > --- a/libselinux/utils/compute_user.c
> > +++ b/libselinux/utils/compute_user.c
> > @@ -27,12 +27,12 @@ int main(int argc, char **argv)
> >
> >         if (!buf[0]) {
> >                 printf("none\n");
> > -               exit(0);
> > +               exit(EXIT_SUCCESS);
> >         }
> >
> >         for (ptr = buf; *ptr; ptr++) {
> >                 printf("%s\n", *ptr);
> >         }
> >         freeconary(buf);
> > -       exit(0);
> > +       exit(EXIT_SUCCESS);
> >  }
> > diff --git a/libselinux/utils/getfilecon.c b/libselinux/utils/getfilecon.c
> > index a7a51abb..6266ae16 100644
> > --- a/libselinux/utils/getfilecon.c
> > +++ b/libselinux/utils/getfilecon.c
> > @@ -23,5 +23,5 @@ int main(int argc, char **argv)
> >                 printf("%s\t%s\n", argv[i], buf);
> >                 freecon(buf);
> >         }
> > -       exit(0);
> > +       exit(EXIT_SUCCESS);
> >  }
> > diff --git a/libselinux/utils/getpidcon.c b/libselinux/utils/getpidcon.c
> > index 3df0da1f..ea6c274e 100644
> > --- a/libselinux/utils/getpidcon.c
> > +++ b/libselinux/utils/getpidcon.c
> > @@ -27,5 +27,5 @@ int main(int argc, char **argv)
> >
> >         printf("%s\n", buf);
> >         freecon(buf);
> > -       exit(0);
> > +       exit(EXIT_SUCCESS);
> >  }
> > diff --git a/libselinux/utils/getseuser.c b/libselinux/utils/getseuser.c
> > index c33a4ad2..9193fe0a 100644
> > --- a/libselinux/utils/getseuser.c
> > +++ b/libselinux/utils/getseuser.c
> > @@ -36,5 +36,5 @@ int main(int argc, char **argv)
> >         for (i = 0; i < n; i++)
> >                 printf("Context %d\t%s\n", i, contextlist[i]);
> >         freeconary(contextlist);
> > -       exit(0);
> > +       exit(EXIT_SUCCESS);
> >  }
> > diff --git a/libselinux/utils/policyvers.c b/libselinux/utils/policyvers.c
> > index 0309d7d1..dd56f2c7 100644
> > --- a/libselinux/utils/policyvers.c
> > +++ b/libselinux/utils/policyvers.c
> > @@ -14,5 +14,5 @@ int main(int argc __attribute__ ((unused)), char **argv)
> >         }
> >
> >         printf("%d\n", rc);
> > -       exit(0);
> > +       exit(EXIT_SUCCESS);
> >  }
> > diff --git a/libselinux/utils/setfilecon.c b/libselinux/utils/setfilecon.c
> > index d69af84a..79af55de 100644
> > --- a/libselinux/utils/setfilecon.c
> > +++ b/libselinux/utils/setfilecon.c
> > @@ -20,5 +20,5 @@ int main(int argc, char **argv)
> >                         exit(2);
> >                 }
> >         }
> > -       exit(0);
> > +       exit(EXIT_SUCCESS);
> >  }
> > --
> > 2.21.0
> >
>
> ack on this as is, since it preserves behavior, but on the usage()
> case I wonder why
> some are not a failure.




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux