Avoid more gcc warning about not checking return values ...

This commit is contained in:
Roy Marples 2009-04-30 19:56:43 +01:00
parent 21e45e895c
commit 3d0e5175d8
4 changed files with 21 additions and 12 deletions

View File

@ -101,7 +101,8 @@ write_log(int logfd, const char *buffer, size_t bytes)
} }
if (!in_escape) { if (!in_escape) {
write(logfd, p++, 1); if (write(logfd, p++, 1) == -1)
eerror("write: %s", strerror(errno));
continue; continue;
} }
@ -128,7 +129,8 @@ rc_logger_close(void)
int sig = SIGTERM; int sig = SIGTERM;
if (signal_pipe[1] > -1) { if (signal_pipe[1] > -1) {
write(signal_pipe[1], &sig, sizeof(sig)); if (write(signal_pipe[1], &sig, sizeof(sig)) == -1)
eerror("write: %s", strerror(errno));
close(signal_pipe[1]); close(signal_pipe[1]);
signal_pipe[1] = -1; signal_pipe[1] = -1;
} }
@ -218,7 +220,8 @@ rc_logger_open(const char *level)
if (fd[1].revents & (POLLIN | POLLHUP)) { if (fd[1].revents & (POLLIN | POLLHUP)) {
memset(buffer, 0, BUFSIZ); memset(buffer, 0, BUFSIZ);
bytes = read(rc_logger_tty, buffer, BUFSIZ); bytes = read(rc_logger_tty, buffer, BUFSIZ);
write(STDOUT_FILENO, buffer, bytes); if (write(STDOUT_FILENO, buffer, bytes) == -1)
eerror("write: %s", strerror(errno));
if (log) if (log)
write_log(fileno (log), buffer, bytes); write_log(fileno (log), buffer, bytes);
@ -255,7 +258,8 @@ rc_logger_open(const char *level)
/* Try and cat our new logfile to a more permament location /* Try and cat our new logfile to a more permament location
and then punt it */ and then punt it */
system(MOVELOG); if (system(MOVELOG) == -1)
eerror("system: %s: %s", MOVELOG, strerror(errno));
exit(0); exit(0);
/* NOTREACHED */ /* NOTREACHED */

View File

@ -191,8 +191,10 @@ proc_getent(const char *ent)
} }
memset(proc, 0, sizeof(proc)); memset(proc, 0, sizeof(proc));
fgets(proc, sizeof(proc), fp); p = fgets(proc, sizeof(proc), fp);
if (*proc && (p = strstr(proc, ent))) { if (p == NULL)
eerror("fgets: %s", strerror(errno));
else if (*proc && (p = strstr(proc, ent))) {
i = p - proc; i = p - proc;
if (i == '\0' || proc[i - 1] == ' ') { if (i == '\0' || proc[i - 1] == ' ') {
p += strlen(ent); p += strlen(ent);
@ -234,7 +236,8 @@ read_key(bool block)
termios.c_cc[VTIME] = 0; termios.c_cc[VTIME] = 0;
} }
tcsetattr(fd, TCSANOW, &termios); tcsetattr(fd, TCSANOW, &termios);
read(fd, &c, 1); if (read(fd, &c, 1) == -1)
eerror("read: %s", strerror(errno));
tcsetattr(fd, TCSANOW, termios_orig); tcsetattr(fd, TCSANOW, termios_orig);
return c; return c;
} }
@ -840,7 +843,8 @@ main(int argc, char **argv)
argv++; argv++;
/* Change dir to / to ensure all scripts don't use stuff in pwd */ /* 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 /* Ensure our environment is pure
* Also, add our configuration to it */ * Also, add our configuration to it */

View File

@ -1106,7 +1106,8 @@ runscript(int argc, char **argv)
usage(EXIT_FAILURE); usage(EXIT_FAILURE);
/* Change dir to / to ensure all init scripts don't use stuff in pwd */ /* Change dir to / to ensure all init scripts don't use stuff in pwd */
chdir("/"); if (chdir("/") == -1)
eerror("chdir: %s", strerror(errno));
if ((runlevel = xstrdup(getenv("RC_RUNLEVEL"))) == NULL) { if ((runlevel = xstrdup(getenv("RC_RUNLEVEL"))) == NULL) {
env_filter(); env_filter();

View File

@ -960,9 +960,9 @@ start_stop_daemon(int argc, char **argv)
if (interpreted && !pidfile) { if (interpreted && !pidfile) {
fp = fopen(exec_file, "r"); fp = fopen(exec_file, "r");
if (fp) { if (fp) {
fgets(line, sizeof(line), fp); p = fgets(line, sizeof(line), fp);
fclose(fp); fclose(fp);
if (line[0] == '#' && line[1] == '!') { if (p != NULL && line[0] == '#' && line[1] == '!') {
p = line + 2; p = line + 2;
/* Strip leading spaces */ /* Strip leading spaces */
while (*p == ' ' || *p == '\t') while (*p == ' ' || *p == '\t')