# HG changeset patch # User Markus Bröker # Date 1229187480 -3600 # Node ID 96d16dfe787a0f66cb60ad5b5553e02e5b7d592d # Parent a1aa30f0f90489e4ef884feae6570f2e8068cb56 We use return EXIT_SUCCESS instead of return 0 committer: Markus Bröker diff --git a/Makefile b/Makefile --- 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 $< ... diff --git a/alpha_beta.c b/alpha_beta.c --- a/alpha_beta.c +++ b/alpha_beta.c @@ -343,5 +343,6 @@ } print (); + return EXIT_SUCCESS; } diff --git a/atoi_print.c b/atoi_print.c --- 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; } diff --git a/bad_alloc.cc b/bad_alloc.cc --- 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; diff --git a/crypt.c b/crypt.c --- a/crypt.c +++ b/crypt.c @@ -33,5 +33,5 @@ printf ("DeCrypted Data: %s\n", data); - return 0; + return EXIT_SUCCESS; } diff --git a/cunit.c b/cunit.c --- 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 (); } diff --git a/data_types.c b/data_types.c --- 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; } diff --git a/database.c b/database.c --- a/database.c +++ b/database.c @@ -5,6 +5,7 @@ */ #include +#include #include #include @@ -55,5 +56,5 @@ PQfinish (conn); - return 0; + return EXIT_SUCCESS; } diff --git a/dnsresolve.c b/dnsresolve.c --- a/dnsresolve.c +++ b/dnsresolve.c @@ -33,5 +33,5 @@ } } - return 0; + return EXIT_SUCCESS; } diff --git a/endian.c b/endian.c --- 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; } diff --git a/file_demo.c b/file_demo.c --- a/file_demo.c +++ b/file_demo.c @@ -41,5 +41,6 @@ close (fd1); close (fd2); - return 0; + + return EXIT_SUCCESS; } diff --git a/floating.c b/floating.c --- a/floating.c +++ b/floating.c @@ -34,5 +34,6 @@ if (values != NULL) free (values); + return EXIT_SUCCESS; } diff --git a/gauss.c b/gauss.c --- 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; } diff --git a/hex2chars.c b/hex2chars.c --- a/hex2chars.c +++ b/hex2chars.c @@ -135,5 +135,5 @@ start = end; } - return 0; + return EXIT_SUCCESS; } diff --git a/life.c b/life.c --- 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 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; } diff --git a/lotto.c b/lotto.c --- a/lotto.c +++ b/lotto.c @@ -248,5 +248,5 @@ free (values); free (numbers); - return 0; + return EXIT_SUCCESS; } diff --git a/md5.c b/md5.c --- a/md5.c +++ b/md5.c @@ -16,5 +16,6 @@ } md5recursive (argv[1], 1); + return EXIT_SUCCESS; } diff --git a/mem2swap.c b/mem2swap.c --- a/mem2swap.c +++ b/mem2swap.c @@ -60,5 +60,6 @@ printf ("\n\n"); execve ("/usr/bin/free", args, NULL); + return EXIT_SUCCESS; } diff --git a/ncurses.c b/ncurses.c --- a/ncurses.c +++ b/ncurses.c @@ -87,5 +87,6 @@ endwin (); printf ("\n"); - return 0; + + return EXIT_SUCCESS; } diff --git a/nomalloc.c b/nomalloc.c --- a/nomalloc.c +++ b/nomalloc.c @@ -5,6 +5,7 @@ */ #include +#include struct Names { char *name; @@ -30,5 +31,5 @@ setStruct (&names); printStruct (&names); - return 0; + return EXIT_SUCCESS; } diff --git a/numerierung.c b/numerierung.c --- a/numerierung.c +++ b/numerierung.c @@ -58,5 +58,6 @@ } fclose (f); + return EXIT_SUCCESS; } diff --git a/recording.c b/recording.c --- a/recording.c +++ b/recording.c @@ -86,5 +86,6 @@ if (status == -1) perror ("SOUND_PCM_SYNC ioctl failed"); } + return EXIT_SUCCESS; } diff --git a/set_limit.c b/set_limit.c --- 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; } diff --git a/testcase.c b/testcase.c --- 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; } diff --git a/threads.c b/threads.c --- a/threads.c +++ b/threads.c @@ -5,12 +5,9 @@ #include #include - #include #include -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; -} diff --git a/urandom.c b/urandom.c --- a/urandom.c +++ b/urandom.c @@ -37,5 +37,6 @@ } close (fd); + return EXIT_SUCCESS; } diff --git a/utf8.c b/utf8.c --- a/utf8.c +++ b/utf8.c @@ -40,5 +40,6 @@ } printf ("DIFF: %d : 0x%2X\n", 0x40, 0x40); - return 0; + + return EXIT_SUCCESS; } diff --git a/xdemo.c b/xdemo.c --- 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; }