[hackers] [sbase] Exit with EXIT_SUCCESS/EXIT_FAILURE instead of 0 and 1 || sin

From: <git_AT_suckless.org>
Date: Mon, 07 Oct 2013 17:45:24 +0200

commit b5a511dacf26655f9eee051ea7bd5fd6709087cf
Author: sin <sin_AT_2f30.org>
Date: Mon Oct 7 16:41:55 2013 +0100

    Exit with EXIT_SUCCESS/EXIT_FAILURE instead of 0 and 1
    
    Fixed for consistency purposes.

diff --git a/basename.c b/basename.c
index 8443132..e3d1a14 100644
--- a/basename.c
+++ b/basename.c
_AT_@ -37,6 +37,6 @@ main(int argc, char *argv[])
 
         puts(s);
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/cal.c b/cal.c
index 2c42ccd..c34be66 100644
--- a/cal.c
+++ b/cal.c
_AT_@ -189,6 +189,6 @@ main(int argc, char *argv[])
 
         drawcal(year, month, day, ncols, nmons, fday);
 
- exit(0);
+ return EXIT_SUCCESS;
 }
 
diff --git a/cat.c b/cat.c
index d994d59..816cb41 100644
--- a/cat.c
+++ b/cat.c
_AT_@ -33,5 +33,5 @@ main(int argc, char *argv[])
                 fclose(fp);
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
diff --git a/chgrp.c b/chgrp.c
index 87a7242..c6807cc 100644
--- a/chgrp.c
+++ b/chgrp.c
_AT_@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <ftw.h>
_AT_@ -55,7 +56,7 @@ main(int argc, char **argv)
                 while(*++argv)
                         ftw(*argv, chgrp, FOPEN_MAX);
 
- return 0;
+ return EXIT_SUCCESS;
         }
         while(*++argv) {
                 if(stat(*argv, &st) == -1) {
diff --git a/chmod.c b/chmod.c
index 2809914..9cdb50e 100644
--- a/chmod.c
+++ b/chmod.c
_AT_@ -37,7 +37,7 @@ main(int argc, char *argv[])
         parsemode(argv[0]);
         for(++argv; argc > 0; argc--)
                 chmodr(argv[0]);
- return 0;
+ return EXIT_SUCCESS;
 }
 
 void
diff --git a/chown.c b/chown.c
index 4f1d9d8..0bdd2e9 100644
--- a/chown.c
+++ b/chown.c
_AT_@ -59,7 +59,7 @@ main(int argc, char *argv[])
         for(; argc > 0; argc--, argv++)
                 chownpwgr(argv[0]);
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 void
diff --git a/chroot.c b/chroot.c
index 52786e5..d913837 100644
--- a/chroot.c
+++ b/chroot.c
_AT_@ -28,7 +28,7 @@ main(int argc, char **argv)
         }
 
         eprintf("chroot: '%s':", argv[2]);
- return 1;
+ return EXIT_FAILURE;
 }
 
 void
diff --git a/comm.c b/comm.c
index 586de78..b90abb3 100644
--- a/comm.c
+++ b/comm.c
_AT_@ -63,7 +63,7 @@ main(int argc, char *argv[])
                 printline((2-dif) % 3, lines[MAX(0, dif)]);
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 void
_AT_@ -101,6 +101,6 @@ finish(int pos, FILE *f, char *name)
         while(nextline(buf, sizeof(buf), f, name))
                 printline(pos, buf);
 
- exit(1);
+ exit(EXIT_FAILURE);
 }
 
diff --git a/date.c b/date.c
index c3baadb..2a798e5 100644
--- a/date.c
+++ b/date.c
_AT_@ -41,6 +41,6 @@ main(int argc, char *argv[])
         strftime(buf, sizeof buf, fmt, now);
         puts(buf);
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/dirname.c b/dirname.c
index 0321078..1c4297f 100644
--- a/dirname.c
+++ b/dirname.c
_AT_@ -24,6 +24,6 @@ main(int argc, char *argv[])
 
         puts(dirname(argv[0]));
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/echo.c b/echo.c
index efe6f27..41ff4bb 100644
--- a/echo.c
+++ b/echo.c
_AT_@ -29,6 +29,6 @@ main(int argc, char *argv[])
         if(!nflag)
                 putchar('
');
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/env.c b/env.c
index fed0985..921db4d 100644
--- a/env.c
+++ b/env.c
_AT_@ -35,7 +35,7 @@ main(int argc, char **argv)
         while(environ && *environ)
                 printf("%s
", *environ++);
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 void
diff --git a/expand.c b/expand.c
index 7ad43b8..beebece 100644
--- a/expand.c
+++ b/expand.c
_AT_@ -50,7 +50,7 @@ main(int argc, char *argv[])
                         argv++;
                 }
         }
- return 0;
+ return EXIT_SUCCESS;
 }
 
 static wint_t
diff --git a/fold.c b/fold.c
index 64d430b..bbbb28a 100644
--- a/fold.c
+++ b/fold.c
_AT_@ -48,7 +48,7 @@ main(int argc, char *argv[])
                 fclose(fp);
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 void
diff --git a/head.c b/head.c
index 500c678..0cf8680 100644
--- a/head.c
+++ b/head.c
_AT_@ -36,7 +36,7 @@ main(int argc, char *argv[])
                 fclose(fp);
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 void
diff --git a/hostname.c b/hostname.c
index 787d302..4a377d9 100644
--- a/hostname.c
+++ b/hostname.c
_AT_@ -1,6 +1,7 @@
 /* See LICENSE file for copyright and license details. */
 #include <unistd.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include "util.h"
 
_AT_@ -29,5 +30,5 @@ main(int argc, char *argv[])
                         eprintf("sethostname:");
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
diff --git a/id.c b/id.c
index 19248d0..09253cc 100644
--- a/id.c
+++ b/id.c
_AT_@ -4,6 +4,7 @@
 #include <pwd.h>
 #include <grp.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <limits.h>
 #include "util.h"
 
_AT_@ -66,5 +67,5 @@ main(int argc, char *argv[])
                 printf("(%s)", gr->gr_name);
         }
         putchar('
');
- return 0;
+ return EXIT_SUCCESS;
 }
diff --git a/kill.c b/kill.c
index f4f4a56..3a65de9 100644
--- a/kill.c
+++ b/kill.c
_AT_@ -74,6 +74,6 @@ main(int argc, char *argv[])
                         eprintf("kill %d:", pid);
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/ln.c b/ln.c
index bcb8d70..a5aa219 100644
--- a/ln.c
+++ b/ln.c
_AT_@ -33,7 +33,7 @@ main(int argc, char *argv[])
 
         enmasse(argc, &argv[0], ln);
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 int
diff --git a/ls.c b/ls.c
index c7c32be..af1336d 100644
--- a/ls.c
+++ b/ls.c
_AT_@ -89,7 +89,7 @@ main(int argc, char *argv[])
         for(i = 0; i < argc; i++)
                 ls(&ents[rflag ? argc-i-1 : i]);
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 int
diff --git a/mc.c b/mc.c
index e18ad51..dcd4e12 100644
--- a/mc.c
+++ b/mc.c
_AT_@ -63,7 +63,7 @@ main(int argc, char *argv[])
                 for(l = 0; l < b.nlines; ++l) {
                         fputs(b.lines[l], stdout);
                 }
- return 0;
+ return EXIT_SUCCESS;
         }
 
         if(!(space = malloc(maxlen + 2)))
_AT_@ -82,6 +82,6 @@ main(int argc, char *argv[])
                 fputs("
", stdout);
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/mkdir.c b/mkdir.c
index 57b2382..8080797 100644
--- a/mkdir.c
+++ b/mkdir.c
_AT_@ -50,7 +50,7 @@ main(int argc, char *argv[])
                                 eprintf("chmod %s:", argv[0]);
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 void
diff --git a/mkfifo.c b/mkfifo.c
index 447c7eb..24015fe 100644
--- a/mkfifo.c
+++ b/mkfifo.c
_AT_@ -28,6 +28,6 @@ main(int argc, char *argv[])
                         eprintf("mkfifo %s:", argv[0]);
                 }
         }
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/mknod.c b/mknod.c
index 3f53b01..da27ddf 100644
--- a/mknod.c
+++ b/mknod.c
_AT_@ -38,5 +38,5 @@ main(int argc, char **argv)
 
         if(mknod(argv[0], type|mode, dev) == -1)
                 eprintf("mknod: '%s':", argv[0]);
- return 0;
+ return EXIT_SUCCESS;
 }
diff --git a/mv.c b/mv.c
index 0d1ec50..542f833 100644
--- a/mv.c
+++ b/mv.c
_AT_@ -34,7 +34,7 @@ main(int argc, char *argv[])
                 eprintf("%s: not a directory
", argv[argc-1]);
         enmasse(argc, &argv[0], mv);
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 int
diff --git a/nl.c b/nl.c
index 601984a..e35b043 100644
--- a/nl.c
+++ b/nl.c
_AT_@ -56,7 +56,7 @@ main(int argc, char *argv[])
                 fclose(fp);
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 void
diff --git a/paste.c b/paste.c
index e4e43c5..7d52930 100644
--- a/paste.c
+++ b/paste.c
_AT_@ -100,7 +100,7 @@ main(int argc, char *argv[])
         free(delim);
         free(dsc);
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 
diff --git a/printenv.c b/printenv.c
index 14fcaf7..828a23f 100644
--- a/printenv.c
+++ b/printenv.c
_AT_@ -12,13 +12,13 @@ main(int argc, char **argv)
                 while(*environ)
                         printf("%s
", *environ++);
 
- return 0;
+ return EXIT_SUCCESS;
         }
         while(*++argv) {
                 if((var = getenv(*argv)))
                         printf("%s
", var);
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/pwd.c b/pwd.c
index 100cc82..d796c31 100644
--- a/pwd.c
+++ b/pwd.c
_AT_@ -31,7 +31,7 @@ main(int argc, char *argv[])
         cwd = agetcwd();
         puts((mode == 'L') ? getpwd(cwd) : cwd);
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 const char *
diff --git a/readlink.c b/readlink.c
index f54fd51..92e2428 100644
--- a/readlink.c
+++ b/readlink.c
_AT_@ -40,7 +40,7 @@ main(int argc, char *argv[])
                 usage();
 
         if (strlen(argv[0]) > PATH_MAX - 1)
- exit(1);
+ return EXIT_FAILURE;
 
         if (fflag) {
                 if (realpath(argv[0], buf) == NULL)
_AT_@ -55,5 +55,5 @@ main(int argc, char *argv[])
         if (!nflag)
                 putchar('
');
 
- return 0;
+ return EXIT_SUCCESS;
 }
diff --git a/renice.c b/renice.c
index 04cb960..9090ea5 100644
--- a/renice.c
+++ b/renice.c
_AT_@ -18,7 +18,7 @@ main(int argc, char **argv)
 {
         const char *adj = NULL;
         long val;
- int i, which = PRIO_PROCESS, status = 0;
+ int i, which = PRIO_PROCESS, status = EXIT_SUCCESS;
 
         ARGBEGIN {
         case 'n':
_AT_@ -55,7 +55,7 @@ main(int argc, char **argv)
                                 who = pwd->pw_uid;
                         else if(errno != 0) {
                                 perror("can't read passwd");
- status = 1;
+ status = EXIT_FAILURE;
                                 continue;
                         }
                 }
_AT_@ -63,7 +63,7 @@ main(int argc, char **argv)
                         who = strtop(argv[i]);
 
                 if(who < 0 || !renice(which, who, val))
- status = 1;
+ status = EXIT_FAILURE;
         }
 
         return status;
diff --git a/rm.c b/rm.c
index 725310c..e1dbdf3 100644
--- a/rm.c
+++ b/rm.c
_AT_@ -33,6 +33,6 @@ main(int argc, char *argv[])
         for(; argc > 0; argc--, argv++)
                 rm(argv[0]);
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/rmdir.c b/rmdir.c
index 7773777..4ef13eb 100644
--- a/rmdir.c
+++ b/rmdir.c
_AT_@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <errno.h>
_AT_@ -23,6 +24,6 @@ main(int argc, char **argv)
                                         argv[-1], strerror(errno));
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/seq.c b/seq.c
index 6f91fd9..4023876 100644
--- a/seq.c
+++ b/seq.c
_AT_@ -86,7 +86,7 @@ main(int argc, char *argv[])
         }
         printf("
");
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 int
diff --git a/setsid.c b/setsid.c
index 2e17540..db37179 100644
--- a/setsid.c
+++ b/setsid.c
_AT_@ -31,7 +31,7 @@ main(int argc, char *argv[])
                 case 0:
                         break;
                 default:
- exit(0);
+ return EXIT_SUCCESS;
                 }
         }
         if(setsid() < 0)
diff --git a/sleep.c b/sleep.c
index 1f6b85a..fc9b20f 100644
--- a/sleep.c
+++ b/sleep.c
_AT_@ -25,6 +25,6 @@ main(int argc, char *argv[])
         seconds = estrtol(argv[0], 0);
         while((seconds = sleep(seconds)) > 0)
                 ;
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/sort.c b/sort.c
index f7b3eb7..078b70f 100644
--- a/sort.c
+++ b/sort.c
_AT_@ -55,7 +55,7 @@ main(int argc, char *argv[])
                 }
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 int
diff --git a/split.c b/split.c
index cf22125..27be8bf 100644
--- a/split.c
+++ b/split.c
_AT_@ -94,7 +94,7 @@ Nextfile:
                 fclose(out);
                 break;
         }
- return 0;
+ return EXIT_SUCCESS;
 
 }
 
diff --git a/sponge.c b/sponge.c
index 8084166..8961339 100644
--- a/sponge.c
+++ b/sponge.c
_AT_@ -1,6 +1,6 @@
 /* See LICENSE file for copyright and license details. */
 #include <stdio.h>
-
+#include <stdlib.h>
 #include "text.h"
 #include "util.h"
 
_AT_@ -36,5 +36,5 @@ main(int argc, char *argv[])
         fclose(fp);
         fclose(tmpfp);
 
- return 0;
+ return EXIT_SUCCESS;
 }
diff --git a/stat.c b/stat.c
index 2e68352..c6f7da6 100644
--- a/stat.c
+++ b/stat.c
_AT_@ -5,6 +5,7 @@
 #include <errno.h>
 #include <inttypes.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <time.h>
 #include "util.h"
 
_AT_@ -20,7 +21,7 @@ int
 main(int argc, char *argv[])
 {
         struct stat st;
- int i, ret = 0;
+ int i, ret = EXIT_SUCCESS;
         int Lflag = 0;
         int (*fn)(const char *, struct stat *);
 
_AT_@ -44,7 +45,7 @@ main(int argc, char *argv[])
                         fprintf(stderr, "%s %s: ", Lflag ? "stat" : "lstat",
                                 argv[i]);
                         perror(NULL);
- ret = 1;
+ ret = EXIT_FAILURE;
                         continue;
                 }
                 show_stat(argv[i], &st);
diff --git a/strings.c b/strings.c
index 55a8f07..ff2ca18 100644
--- a/strings.c
+++ b/strings.c
_AT_@ -31,7 +31,7 @@ main(int argc, char *argv[])
                 dostrings(stdin, "<stdin>");
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 static void
diff --git a/sync.c b/sync.c
index db21d8a..cb4ad12 100644
--- a/sync.c
+++ b/sync.c
_AT_@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include "util.h"
 
_AT_@ -15,6 +16,6 @@ main(int argc, char **argv)
                 usage();
         sync();
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/tail.c b/tail.c
index e45d924..da222b6 100644
--- a/tail.c
+++ b/tail.c
_AT_@ -43,7 +43,7 @@ main(int argc, char *argv[])
         } else
                 usage();
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 void
diff --git a/tar.c b/tar.c
index c1cc88d..4585d95 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -140,7 +140,7 @@ main(int argc, char *argv[])
                 xt((mode == 'x') ? unarchive : print);
         }
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 void
diff --git a/tee.c b/tee.c
index eaf3c01..181bad7 100644
--- a/tee.c
+++ b/tee.c
_AT_@ -47,6 +47,6 @@ main(int argc, char *argv[])
         if(ferror(stdin))
                 eprintf("<stdin>: read error:");
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/touch.c b/touch.c
index a1391a2..7187fc3 100644
--- a/touch.c
+++ b/touch.c
_AT_@ -42,7 +42,7 @@ main(int argc, char *argv[])
         for(; argc > 0; argc--, argv++)
                 touch(argv[0]);
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 void
diff --git a/tty.c b/tty.c
index 6bb77ae..a9d64bd 100644
--- a/tty.c
+++ b/tty.c
_AT_@ -22,5 +22,5 @@ main(int argc, char *argv[])
 
         tty = ttyname(STDIN_FILENO);
         puts(tty ? tty : "not a tty");
- return tty ? 0 : 1;
+ return tty ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/uname.c b/uname.c
index 84e318b..44254c7 100644
--- a/uname.c
+++ b/uname.c
_AT_@ -59,6 +59,6 @@ main(int argc, char *argv[])
                 putword(u.machine);
         putchar('
');
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/uniq.c b/uniq.c
index 9c85668..3b2c13c 100644
--- a/uniq.c
+++ b/uniq.c
_AT_@ -57,7 +57,7 @@ main(int argc, char *argv[])
                 usage();
         uniq_finish();
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
 void
diff --git a/unlink.c b/unlink.c
index c365680..6e6d883 100644
--- a/unlink.c
+++ b/unlink.c
_AT_@ -1,4 +1,5 @@
 #include <unistd.h>
+#include <stdlib.h>
 #include "util.h"
 
 static void
_AT_@ -16,6 +17,6 @@ main(int argc, char **argv)
         if(unlink(argv[1]) == -1)
                 eprintf("unlink: '%s':", argv[1]);
 
- return 0;
+ return EXIT_SUCCESS;
 }
 
diff --git a/util/crypt.c b/util/crypt.c
index 326b028..5182993 100644
--- a/util/crypt.c
+++ b/util/crypt.c
_AT_@ -23,7 +23,7 @@ cryptmain(int argc, char *argv[],
                         argv++;
                 }
         }
- return 0;
+ return EXIT_SUCCESS;
 }
 
 int
diff --git a/who.c b/who.c
index e098c99..bd4a701 100644
--- a/who.c
+++ b/who.c
_AT_@ -57,6 +57,6 @@ main(int argc, char **argv)
                 printf("%-8s %-12s %-16s
", usr.ut_name, usr.ut_line, timebuf);
         }
         fclose(ufp);
- return 0;
+ return EXIT_SUCCESS;
 }
 
Received on Mon Oct 07 2013 - 17:45:24 CEST

This archive was generated by hypermail 2.3.0 : Mon Oct 07 2013 - 17:48:17 CEST