From 3d0e5175d845c2386295cf454f9ee1939265fe59 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Thu, 30 Apr 2009 19:56:43 +0100 Subject: Avoid more gcc warning about not checking return values ... --- src/rc/rc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/rc/rc.c') diff --git a/src/rc/rc.c b/src/rc/rc.c index 9b4a7e5..405ea54 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -191,8 +191,10 @@ proc_getent(const char *ent) } memset(proc, 0, sizeof(proc)); - fgets(proc, sizeof(proc), fp); - if (*proc && (p = strstr(proc, ent))) { + p = fgets(proc, sizeof(proc), fp); + if (p == NULL) + eerror("fgets: %s", strerror(errno)); + else if (*proc && (p = strstr(proc, ent))) { i = p - proc; if (i == '\0' || proc[i - 1] == ' ') { p += strlen(ent); @@ -234,7 +236,8 @@ read_key(bool block) termios.c_cc[VTIME] = 0; } tcsetattr(fd, TCSANOW, &termios); - read(fd, &c, 1); + if (read(fd, &c, 1) == -1) + eerror("read: %s", strerror(errno)); tcsetattr(fd, TCSANOW, termios_orig); return c; } @@ -840,7 +843,8 @@ main(int argc, char **argv) argv++; /* Change dir to / to ensure all scripts don't use stuff in pwd */ - chdir("/"); + if (chdir("/") == -1) + eerror("chdir: %s", strerror(errno)); /* Ensure our environment is pure * Also, add our configuration to it */ -- cgit v1.2.3