]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Clean up compiler warnings from overly pedantic checking.
authorRoy Marples <roy@marples.name>
Thu, 29 Jan 2009 13:09:23 +0000 (13:09 +0000)
committerRoy Marples <roy@marples.name>
Thu, 29 Jan 2009 13:09:23 +0000 (13:09 +0000)
client.c
common.c
dhcpcd.c
signals.c

index d599d1bb8a5aae441c03755b88e8f5d34d644597..3fd0aecd6f65fcfe52bc03ec78542d96a7d0ca51 100644 (file)
--- a/client.c
+++ b/client.c
@@ -217,7 +217,8 @@ daemonise(struct if_state *state, const struct options *options)
                        setsid();
                        /* Notify parent it's safe to exit as we've detached. */
                        close(sidpipe[0]);
-                       write(sidpipe[1], &buf, 1);
+                       if (write(sidpipe[1], &buf, 1) != 1)
+                               logger(LOG_ERR, "write: %s", strerror(errno));
                        close(sidpipe[1]);
                        close_fds();
                        break;
@@ -226,7 +227,8 @@ daemonise(struct if_state *state, const struct options *options)
                        signal_reset();
                        /* Wait for child to detach */
                        close(sidpipe[1]);
-                       read(sidpipe[0], &buf, 1);
+                       if (read(sidpipe[0], &buf, 1) != 1)
+                               logger(LOG_ERR, "read: %s", strerror(errno));
                        close(sidpipe[0]);
                        break;
        }
index 3e8d92e20ce8769bd6bb3fdd7fa5227a23199b88..da22a5cd59529ec44782190dfa27d0bcc37059ca 100644 (file)
--- a/common.c
+++ b/common.c
@@ -69,7 +69,8 @@ get_line(char **line, size_t *len, FILE *fp)
                }
                p = *line + last;
                memset(p, 0, BUFSIZ);
-               fgets(p, BUFSIZ, fp);
+               if (fgets(p, BUFSIZ, fp) == NULL)
+                       break;
                last += strlen(p);
                if (last && (*line)[last - 1] == '\n') {
                        (*line)[last - 1] = '\0';
index 9e03605c6f6f5ca9d976c3d9481ac7d2fbff2f25..1c35491c23004563c1c74bba19e029f465c27400 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -137,14 +137,15 @@ static pid_t
 read_pid(const char *pidfile)
 {
        FILE *fp;
-       pid_t pid = 0;
+       pid_t pid;
 
        if ((fp = fopen(pidfile, "r")) == NULL) {
                errno = ENOENT;
                return 0;
        }
 
-       fscanf(fp, "%d", &pid);
+       if (fscanf(fp, "%d", &pid) != 1)
+               pid = 0;
        fclose(fp);
 
        return pid;
@@ -878,7 +879,8 @@ main(int argc, char **argv)
                goto abort;
        }
 
-       chdir("/");
+       if (chdir("/") == -1)
+               logger(LOG_ERR, "chdir `/': %s", strerror(errno));
        umask(022);
 
        if (sig != 0 && !(options->options & DHCPCD_DAEMONISED)) {
index 58679d63410b43d35ecd7d8dcf7f9a8806ad3cdb..daf0347616aa9251298e0afe691e43c9d6fcffb0 100644 (file)
--- a/signals.c
+++ b/signals.c
@@ -31,6 +31,7 @@
 #include <errno.h>
 #include <signal.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 
 #include "common.h"
@@ -50,7 +51,8 @@ signal_handler(int sig)
 {
        int serrno = errno;
 
-       write(signal_pipe[1], &sig, sizeof(sig));
+       if (write(signal_pipe[1], &sig, sizeof(sig)) != sizeof(sig))
+               syslog(LOG_ERR, "write signal %d: %s", sig, strerror(errno));
        /* Restore errno */
        errno = serrno;
 }