# HG changeset patch # User Markus Bröker # Date 1239878952 -7200 # Node ID b94d657a9acb54a0bdcd13c087b7fe596227a9af # Parent 63adb261de90f88409c2b3dcfa098d94cfdcc016 Policy Inonsistency on many files * Whenever a piece of software terminates unexpected, * catched or not, with a help screen or not, * it indicates an ERROR and the software ==> return(s) EXIT_FAILURE committer: Markus Bröker diff --git a/alpha_beta.c b/alpha_beta.c --- a/alpha_beta.c +++ b/alpha_beta.c @@ -48,7 +48,7 @@ { Node *actual; - if ((actual = malloc (sizeof (Node) + 1)) == NULL) { + if ((actual = malloc (sizeof (Node))) == NULL) { perror ("MALLOC"); exit (EXIT_FAILURE); } @@ -176,7 +176,7 @@ continue; } - if ((move = malloc (sizeof (Move) + 1)) == NULL) { + if ((move = malloc (sizeof (Move))) == NULL) { perror ("MALLOC"); exit (EXIT_FAILURE); } @@ -303,7 +303,7 @@ else depth = 1; - if ((actual = malloc (sizeof (Node) + 1)) == NULL) { + if ((actual = malloc (sizeof (Node))) == NULL) { perror ("MALLOC"); return EXIT_FAILURE; } diff --git a/connection.c b/connection.c --- a/connection.c +++ b/connection.c @@ -55,7 +55,7 @@ if (argc != 3) { printf ("Usage: %s \n", argv[0]); - return EXIT_SUCCESS; + return EXIT_FAILURE; } if ((sockfd = connection (argv[1], atoi (argv[2]))) < 0) { diff --git a/db_bridge/main.cpp b/db_bridge/main.cpp --- a/db_bridge/main.cpp +++ b/db_bridge/main.cpp @@ -20,7 +20,7 @@ std::cout << "\n"; std::cout << "\t\tDATABASE\t\tVerbindung zur Datenbank DATABASE herstellen\n"; std::cout << "\nBerichten Sie Fehler oder Anregungen an mbroeker@largo.homelinux.org" << std::endl; - exit (0); + exit (EXIT_FAILURE); } int main (int argc, char **argv) diff --git a/dnsresolve.c b/dnsresolve.c --- a/dnsresolve.c +++ b/dnsresolve.c @@ -19,7 +19,7 @@ if (argc != 2) { fprintf (stderr, "Usage: %s hostname\n", argv[0]); - exit (0); + return EXIT_FAILURE; } he = gethostbyname (argv[1]); diff --git a/gauss.c b/gauss.c --- a/gauss.c +++ b/gauss.c @@ -99,7 +99,7 @@ printf ("Benutzung: %s UNBEKANNTE\n", argv[0]); printf ("Berechnet ein lineares Gleichungssystem mit n UNBEKANNTEN und n Zeilen ( nxn ).\n"); printf ("Praktische Beispiele stehen in der README Datei.\n"); - return EXIT_SUCCESS; + return EXIT_FAILURE; } MAXY = atoi (argv[1]); @@ -107,7 +107,7 @@ if ((A = calloc (MAXY, sizeof (float *))) == NULL) { printf ("Nicht genug Speicher verfuegbar\n"); - return EXIT_SUCCESS; + return EXIT_FAILURE; } for (i = 0; i < MAXY; i++) { @@ -117,7 +117,7 @@ free (A[k]); free (A); - return EXIT_SUCCESS; + return EXIT_FAILURE; } } diff --git a/hex2chars.c b/hex2chars.c --- a/hex2chars.c +++ b/hex2chars.c @@ -115,7 +115,7 @@ if (argc != 2) { printf ("Usage: %s \n", argv[0]); - exit (0); + return EXIT_FAILURE; } start = argv[1]; diff --git a/life.c b/life.c --- a/life.c +++ b/life.c @@ -107,7 +107,7 @@ { char *arena[MAX]; - if (argc > 2) + if (argc > 1) printf ("Usage: %s\n", argv[0]); if (init_life (arena) == 0) diff --git a/max.c b/max.c --- a/max.c +++ b/max.c @@ -18,7 +18,7 @@ if (argc != 3) { printf ("Usage: %s value1 value2\n", argv[0]); - return EXIT_SUCCESS; + return EXIT_FAILURE; } a = atoi (argv[1]); b = atoi (argv[2]); diff --git a/mem2swap.c b/mem2swap.c --- a/mem2swap.c +++ b/mem2swap.c @@ -44,9 +44,9 @@ } if ((p = malloc (N * size)) == NULL) - return EXIT_SUCCESS; + return EXIT_FAILURE; - while (1) { + for (;;) { for (i = 0; i < N; i++) { p[n * N + i] = size * (n * N + i); } diff --git a/parser/c_compiler/main.c b/parser/c_compiler/main.c --- a/parser/c_compiler/main.c +++ b/parser/c_compiler/main.c @@ -22,7 +22,7 @@ if (argc < 2) { usage (argv[0]); - return EXIT_SUCCESS; + return EXIT_FAILURE; } if ((fp = fopen (argv[1], "r")) == NULL) { diff --git a/parser/calc/main.c b/parser/calc/main.c --- a/parser/calc/main.c +++ b/parser/calc/main.c @@ -4,11 +4,13 @@ */ #include +#include extern int yyparse (); int main (int argc, char **argv) { yyparse (); - return 0; + + return EXIT_SUCCESS; } diff --git a/prog_limit.c b/prog_limit.c --- a/prog_limit.c +++ b/prog_limit.c @@ -20,7 +20,7 @@ if (argc < 3) { printf ("Usage: %s [args]...\n", argv[0]); printf ("Report bugs to mbroeker@largo.homelinux.org\n"); - return EXIT_SUCCESS; + return EXIT_FAILURE; } if ((args = calloc ((argc - 2), sizeof (char *))) == NULL) { diff --git a/recording.c b/recording.c --- a/recording.c +++ b/recording.c @@ -39,7 +39,7 @@ printf ("Usage: %s \n", argv[0]); printf ("Example: %s /dev/dsp\n", argv[0]); printf ("Example: %s /dev/dsp1\n", argv[0]); - return EXIT_SUCCESS; + return EXIT_FAILURE; } fd = open (argv[1], O_RDWR); diff --git a/recursive_compiler.c b/recursive_compiler.c --- a/recursive_compiler.c +++ b/recursive_compiler.c @@ -3,8 +3,8 @@ * Adapted from: http://de.wikipedia.org/wiki/Compiler */ +#include #include -#include #include #define MODE_POSTFIX 0 @@ -110,5 +110,5 @@ lookahead = *expression; expr (); - return 0; + return EXIT_SUCCESS; } diff --git a/sort.c b/sort.c --- a/sort.c +++ b/sort.c @@ -103,5 +103,5 @@ for (i = 0; i < MAX; i++) printf ("%2d %2d %2d\n", a[i], b[i], c[i]); - return 0; + return EXIT_SUCCESS; } diff --git a/testcase.c b/testcase.c --- a/testcase.c +++ b/testcase.c @@ -16,7 +16,7 @@ if (argc != 4) { printf ("Usage: %s (char*)string (char*)delim1 (char*)delim2\n", argv[0]); - return 0; + return EXIT_FAILURE; } snprintf (line, 80, "%s\r\n", argv[1]); diff --git a/tree.c b/tree.c --- a/tree.c +++ b/tree.c @@ -38,9 +38,11 @@ if ((t->next = malloc (sizeof (T))) == NULL) break; t->next->data = GETRANDOM (rand_max); - t->next->next = NULL; t = t->next; } + + t->next = NULL; + return first; } @@ -50,7 +52,7 @@ if (argc != 3) { printf ("Usage: %s elements rand_max\n", argv[0]); - return EXIT_SUCCESS; + return EXIT_FAILURE; } t = make_list (atoi (argv[1]), atoi (argv[2])); diff --git a/utf8.c b/utf8.c --- a/utf8.c +++ b/utf8.c @@ -31,7 +31,7 @@ dest[2] = 0; dest[3] = 0; if (wctomb (dest, (*str)) == -1) - return -1; + return EXIT_FAILURE; printf ("%lc -> [%4X] (%2X:%2X:%2X:%2X)\n", *str, *str, (u_char) dest[0], (u_char) dest[1], (u_char) dest[2], (u_char) dest[3]); diff --git a/xdemo.c b/xdemo.c --- a/xdemo.c +++ b/xdemo.c @@ -19,14 +19,14 @@ if (dpy == NULL) { printf ("Error opening localhost:0\n"); - return EXIT_SUCCESS; + return EXIT_FAILURE; } XSynchronize (dpy, 1); w = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy), 0, 0, 240, 60, 1, 1, 1); if (w < 0) - return EXIT_SUCCESS; + return EXIT_FAILURE; printf ("WINDOW-ID: %ld\n", w);