We use return EXIT_SUCCESS instead of return 0
authorMarkus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 17:58:00 +0100
changeset 8 96d16dfe787a
parent 7 a1aa30f0f904
child 9 c3fecc82ade6
We use return EXIT_SUCCESS instead of return 0 committer: Markus Bröker <mbroeker@largo.homelinux.org>
Makefile
alpha_beta.c
atoi_print.c
bad_alloc.cc
crypt.c
cunit.c
data_types.c
database.c
dnsresolve.c
endian.c
file_demo.c
floating.c
gauss.c
hex2chars.c
life.c
lotto.c
md5.c
mem2swap.c
ncurses.c
nomalloc.c
numerierung.c
recording.c
set_limit.c
testcase.c
threads.c
urandom.c
utf8.c
xdemo.c
--- a/Makefile
+++ b/Makefile
@@ -201,9 +201,10 @@
 	@$(CPP) -o $@ prog_limit.o set_limit.o
 
 database: database.c
-	$(CC) -c -I$(shell pg_config --includedir) $<
+	@echo Compiling $< ...
+	@$(CC) -c -I$(shell pg_config --includedir) $<
 	@echo Linking $< ...
-	$(CC) -lpq -o $@ $@.o
+	@$(CC) -lpq -o $@ $@.o
 
 gauss: gauss.o
 	@echo Linking $< ...
--- a/alpha_beta.c
+++ b/alpha_beta.c
@@ -343,5 +343,6 @@
     }
 
     print ();
+
     return EXIT_SUCCESS;
 }
--- a/atoi_print.c
+++ b/atoi_print.c
@@ -13,5 +13,6 @@
 
     for (i = 1; i < argc; i++)
         printf ("atoi(%s):=%d\n", argv[i], atoi (argv[i]));
-    return 0;
+
+    return EXIT_SUCCESS;
 }
--- a/bad_alloc.cc
+++ b/bad_alloc.cc
@@ -32,8 +32,7 @@
         for (;;) {
             v.push_back (i++);
         }
-    }
-    catch (exception & e) {
+    } catch (exception & e) {
         cout << e.what () << " after " << i << " iterations" << endl << endl;
         cout << "Would you like to see the full error message? (y/n) ";
         cin >> action;
--- a/crypt.c
+++ b/crypt.c
@@ -33,5 +33,5 @@
 
     printf ("DeCrypted Data: %s\n", data);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
--- a/cunit.c
+++ b/cunit.c
@@ -131,5 +131,6 @@
     CU_basic_set_mode (CU_BRM_VERBOSE);
     CU_basic_run_tests ();
     CU_cleanup_registry ();
+
     return CU_get_error ();
 }
--- a/data_types.c
+++ b/data_types.c
@@ -57,5 +57,5 @@
     printf ("\n%20s %4d \t\t %#1.2g \t\t %#1.2g\n", "float", 8 * sizeof (float), (double)FLT_MIN, (double)FLT_MAX);
     printf ("%20s %4d \t\t %#1.2g \t\t %#1.2g\n", "double", 8 * sizeof (double), (double)DBL_MIN, (double)DBL_MAX);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
--- a/database.c
+++ b/database.c
@@ -5,6 +5,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <libpq-fe.h>
 
@@ -55,5 +56,5 @@
 
     PQfinish (conn);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
--- a/dnsresolve.c
+++ b/dnsresolve.c
@@ -33,5 +33,5 @@
         }
     }
 
-    return 0;
+    return EXIT_SUCCESS;
 }
--- a/endian.c
+++ b/endian.c
@@ -17,5 +17,6 @@
 int main (int argc, char **argv)
 {
     printf ("%s Endian System\n", (endian ())? "Big" : "Little");
+
     return EXIT_SUCCESS;
 }
--- a/file_demo.c
+++ b/file_demo.c
@@ -41,5 +41,6 @@
 
     close (fd1);
     close (fd2);
-    return 0;
+
+    return EXIT_SUCCESS;
 }
--- a/floating.c
+++ b/floating.c
@@ -34,5 +34,6 @@
 
     if (values != NULL)
         free (values);
+
     return EXIT_SUCCESS;
 }
--- a/gauss.c
+++ b/gauss.c
@@ -79,7 +79,9 @@
         printf ("Division by Zero\n");
         exit (-1);
     }
-    /*h=A[0][0];*/
+    /*
+     * h=A[0][0];
+     */
     A[0][0] /= h;
     A[0][MAXX - 1] /= h;
 }
--- a/hex2chars.c
+++ b/hex2chars.c
@@ -135,5 +135,5 @@
         start = end;
     }
 
-    return 0;
+    return EXIT_SUCCESS;
 }
--- a/life.c
+++ b/life.c
@@ -25,7 +25,7 @@
     while (inp == NULL) {
         printf ("Please enter the file name>> ");
         if (scanf ("%s", file) < 1)
-			return -1;
+            return -1;
 
         inp = fopen (file, "r");
     }
@@ -38,8 +38,8 @@
                 return fclose (inp);
             }
 
-            if ( (fscanf (inp, "%c ", &org)) < 1 )
-				return -1;
+            if ((fscanf (inp, "%c ", &org)) < 1)
+                return -1;
 
             arena[i][j] = org;
             printf ("%c ", arena[i][j]);
@@ -57,8 +57,8 @@
     for (i = 0; i < MAX; i++) {
         if ((arena[i] = malloc (MAX + 1)) == NULL)
             return -1;
-		for (j=0;j<MAX;j++)
-			arena[i][j] = '.';
+        for (j = 0; j < MAX; j++)
+            arena[i][j] = '.';
     }
 
     for (i = 0; i < MAX; i++) {
@@ -107,12 +107,12 @@
 {
     char *arena[MAX];
 
-	if (argc > 2)
-		printf("Usage: %s\n", argv[0]);
+    if (argc > 2)
+        printf ("Usage: %s\n", argv[0]);
 
     if (init_life (arena) == 0)
-    	show_life (arena);
+        show_life (arena);
     free_life (arena);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
--- a/lotto.c
+++ b/lotto.c
@@ -248,5 +248,5 @@
     free (values);
     free (numbers);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
--- a/md5.c
+++ b/md5.c
@@ -16,5 +16,6 @@
     }
 
     md5recursive (argv[1], 1);
+
     return EXIT_SUCCESS;
 }
--- a/mem2swap.c
+++ b/mem2swap.c
@@ -60,5 +60,6 @@
 
     printf ("\n\n");
     execve ("/usr/bin/free", args, NULL);
+
     return EXIT_SUCCESS;
 }
--- a/ncurses.c
+++ b/ncurses.c
@@ -87,5 +87,6 @@
     endwin ();
 
     printf ("\n");
-    return 0;
+
+    return EXIT_SUCCESS;
 }
--- a/nomalloc.c
+++ b/nomalloc.c
@@ -5,6 +5,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 
 struct Names {
     char *name;
@@ -30,5 +31,5 @@
     setStruct (&names);
     printStruct (&names);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
--- a/numerierung.c
+++ b/numerierung.c
@@ -58,5 +58,6 @@
     }
 
     fclose (f);
+
     return EXIT_SUCCESS;
 }
--- a/recording.c
+++ b/recording.c
@@ -86,5 +86,6 @@
         if (status == -1)
             perror ("SOUND_PCM_SYNC ioctl failed");
     }
+
     return EXIT_SUCCESS;
 }
--- a/set_limit.c
+++ b/set_limit.c
@@ -15,5 +15,6 @@
     rlim.rlim_max = 1.25 * megs;
     if (megs > (4 * 1024 * 1024))
         return setrlimit (RLIMIT_AS, &rlim);
+
     return -1;
 }
--- a/testcase.c
+++ b/testcase.c
@@ -14,7 +14,6 @@
 {
     char line[83];
     char *token;
-    int i;
 
     if (argc != 4) {
         printf ("Usage: %s (char*)string (char*)delim1 (char*)delim2\n", argv[0]);
@@ -30,26 +29,7 @@
         token = strtok (NULL, argv[3]);
     }
 
-    i = 0;
-    printf ("while i++ <5: ");
-    while (i++ < 5)
-        printf ("%d ", i);
-
-    i = 0;
-    printf ("\nwhile ++i <5: ");
-    while (++i < 5)
-        printf ("%d ", i);
+    printf ("\nTest finished\n");
 
-    i = 0;
-    printf ("\nwhile i <5  : ");
-    while (i < 5)
-        printf ("%d ", i++);
-
-    i = 0;
-    printf ("\nwhile i <5  : ");
-    while (i < 5)
-        printf ("%d ", ++i);
-
-    printf ("\nTest finished\n");
-    return 0;
+    return EXIT_SUCCESS;
 }
--- a/threads.c
+++ b/threads.c
@@ -5,12 +5,9 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-
 #include <pthread.h>
 #include <time.h>
 
-void *thread_func (void *vptr_args);
-
 void do_some_work (void)
 {
     time_t start_time = time (NULL);
@@ -18,6 +15,18 @@
     while (time (NULL) == start_time);  /* busy-wait for 0-1 seconds */
 }
 
+void *thread_func (void *vptr_args)
+{
+    int i;
+
+    for (i = 0; i < 20; ++i) {
+        fprintf (stderr, "  b\n");
+
+        do_some_work ();
+    }
+    return NULL;
+}
+
 int main (int argc, char **argv)
 {
     int i;
@@ -33,17 +42,6 @@
 
     pthread_join (thread, NULL);
 
-    exit (EXIT_SUCCESS);
+    return EXIT_SUCCESS;
 }
 
-void *thread_func (void *vptr_args)
-{
-    int i;
-
-    for (i = 0; i < 20; ++i) {
-        fprintf (stderr, "  b\n");
-
-        do_some_work ();
-    }
-    return NULL;
-}
--- a/urandom.c
+++ b/urandom.c
@@ -37,5 +37,6 @@
     }
 
     close (fd);
+
     return EXIT_SUCCESS;
 }
--- a/utf8.c
+++ b/utf8.c
@@ -40,5 +40,6 @@
     }
 
     printf ("DIFF: %d : 0x%2X\n", 0x40, 0x40);
-    return 0;
+
+    return EXIT_SUCCESS;
 }
--- a/xdemo.c
+++ b/xdemo.c
@@ -40,9 +40,9 @@
         XNextEvent (dpy, &xev);
         switch (xev.type) {
         case KeyPress:
-			if(xev.xkey.keycode == 9)
-	            active = 0;
-			printf("Keycode = %2u\n", xev.xkey.keycode);
+            if (xev.xkey.keycode == 9)
+                active = 0;
+            printf ("Keycode = %2u\n", xev.xkey.keycode);
             break;
         default:
             printf ("Unknown Event: %d\n", xev.type);
@@ -51,5 +51,6 @@
 
     XDestroyWindow (dpy, w);
     XCloseDisplay (dpy);
-    return 0;
+
+    return EXIT_SUCCESS;
 }