SELinux Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] Global replace exit(0) with more readable exit(EXIT_SUCCESS)
@ 2019-05-10 18:17 Jokke Hämäläinen
  2019-05-10 21:00 ` William Roberts
  0 siblings, 1 reply; 3+ messages in thread
From: Jokke Hämäläinen @ 2019-05-10 18:17 UTC (permalink / raw)
  To: selinux



---
 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);
 		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


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

* Re: [PATCH] Global replace exit(0) with more readable exit(EXIT_SUCCESS)
  2019-05-10 18:17 [PATCH] Global replace exit(0) with more readable exit(EXIT_SUCCESS) Jokke Hämäläinen
@ 2019-05-10 21:00 ` William Roberts
  2019-05-16  0:34   ` William Roberts
  0 siblings, 1 reply; 3+ messages in thread
From: William Roberts @ 2019-05-10 21:00 UTC (permalink / raw)
  To: Jokke Hämäläinen, Daniel J Walsh; +Cc: selinux

On Fri, May 10, 2019 at 12:03 PM Jokke Hämäläinen
<jokke.hamalainen@kolttonen.fi> 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.

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

* Re: [PATCH] Global replace exit(0) with more readable exit(EXIT_SUCCESS)
  2019-05-10 21:00 ` William Roberts
@ 2019-05-16  0:34   ` William Roberts
  0 siblings, 0 replies; 3+ messages in thread
From: William Roberts @ 2019-05-16  0:34 UTC (permalink / raw)
  To: Jokke Hämäläinen, Daniel J Walsh; +Cc: selinux

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

On Fri, May 10, 2019 at 2:00 PM William Roberts
<bill.c.roberts@gmail.com> wrote:
>
> On Fri, May 10, 2019 at 12:03 PM Jokke Hämäläinen
> <jokke.hamalainen@kolttonen.fi> 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.

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-10 18:17 [PATCH] Global replace exit(0) with more readable exit(EXIT_SUCCESS) Jokke Hämäläinen
2019-05-10 21:00 ` William Roberts
2019-05-16  0:34   ` William Roberts

SELinux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/selinux/0 selinux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 selinux selinux/ https://lore.kernel.org/selinux \
		selinux@vger.kernel.org selinux@archiver.kernel.org
	public-inbox-index selinux


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.selinux


AGPL code for this site: git clone https://public-inbox.org/ public-inbox