# HG changeset patch # User Markus Bröker # Date 1275430952 -7200 # Node ID b5ad49852adc8f59dc3e089ebcdf119d80cc421e # Parent f4b424b93e452b8076966a250a27b431c20c1de8 check for the return values committer: Markus Bröker diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC = gcc -g -ggdb $(PROF) CPP = g++ -g -ggdb $(PROF) CFLAGS = -Wall -O2 -Iinclude $(EXTRA) - EXTRA = -D_XOPEN_SOURCE + EXTRA = LDFLAGS = -L/usr/lib RM = rm -f FIND = find diff --git a/connection.c b/connection.c --- a/connection.c +++ b/connection.c @@ -67,7 +67,10 @@ return EXIT_FAILURE; } - write (sockfd, "GET /\r\n", 7); + if (write (sockfd, "GET /\r\n", 7) == -1) { + perror ("write"); + return EXIT_FAILURE; + } while ((num = read (sockfd, buffer, 1023)) != 0) { buffer[num] = 0; diff --git a/counter.c b/counter.c --- a/counter.c +++ b/counter.c @@ -25,7 +25,9 @@ start = time_str->tm_hour * 60 * 60 + time_str->tm_min * 60 + time_str->tm_sec; - system (argv[1]); + if (system (argv[1]) == -1) { + return EXIT_FAILURE; + } time (&t); time_str = gmtime (&t); diff --git a/crypt.c b/crypt.c --- a/crypt.c +++ b/crypt.c @@ -3,6 +3,8 @@ * Copyright (C) 2008 Markus Broeker */ +#define _XOPEN_SOURCE 500 + #include #include #include diff --git a/daemon.c b/daemon.c --- a/daemon.c +++ b/daemon.c @@ -32,7 +32,8 @@ strftime (time_stamp, sizeof (time_stamp), "%a %d %T", localtime (&t)); len = snprintf (response, sizeof (response), "%s %s", time_stamp, buffer); - write (fd, response, len); + if (write (fd, response, len) == -1) + perror ("write"); } void sigproc () @@ -80,7 +81,10 @@ sanity_check (argc, argv); - daemon (0, 0); + if (daemon (0, 0) == -1) { + perror ("daemon"); + return EXIT_FAILURE; + } signal (SIGTERM, sigproc); for (;;) { diff --git a/file_demo.c b/file_demo.c --- a/file_demo.c +++ b/file_demo.c @@ -22,8 +22,10 @@ return -1; mode = strtoul (argv[1], NULL, 8); - system ("/bin/rm -f /home/mbroeker/Desktop/test1.txt"); - system ("/bin/rm -f /home/mbroeker/Desktop/test2.txt"); + if (system ("/bin/rm -f /home/mbroeker/Desktop/test1.txt") != 0) + return EXIT_FAILURE; + if (system ("/bin/rm -f /home/mbroeker/Desktop/test2.txt") != 0) + return EXIT_FAILURE; /* * Opens ReadOnly diff --git a/files.c b/files.c --- a/files.c +++ b/files.c @@ -58,7 +58,8 @@ } close (fd); } - chdir (".."); + if (chdir ("..") == -1) + break; } return EXIT_SUCCESS; } diff --git a/recursive_compiler.c b/recursive_compiler.c --- a/recursive_compiler.c +++ b/recursive_compiler.c @@ -98,7 +98,8 @@ int main (int argc, char **argv) { printf ("Bitte geben Sie einen Ausdruck in Infix-Notation ein:\n\n\t"); - fgets (expression, MAX, stdin); + if (fgets (expression, MAX, stdin) == NULL) + return EXIT_FAILURE; printf ("\nCompilierter Ausdruck in Postfix-Notation:\n\n\t"); compile_mode = MODE_POSTFIX;