/* Child process. */
close(fds[0]);
make_pidfile();
- write(fds[1], &c, 1);
+ ignore(write(fds[1], &c, 1));
close(fds[1]);
setsid();
if (chdir_) {
- chdir("/");
+ ignore(chdir("/"));
}
time_postfork();
lockfile_postfork();
return true;
} else {
char buf[_POSIX_PIPE_BUF];
- read(fds[0], buf, sizeof buf);
+ ignore(read(fds[0], buf, sizeof buf));
return false;
}
}
}
}
}
- write(fds[1], "", 1);
+ ignore(write(fds[1], "", 1));
}
static bool
signal_poll(struct signal *s)
{
char buf[_POSIX_PIPE_BUF];
- read(fds[0], buf, sizeof buf);
+ ignore(read(fds[0], buf, sizeof buf));
if (signaled[s->signr]) {
signaled[s->signr] = 0;
return true;
signal_handler(int signr)
{
if (signr >= 1 && signr < N_SIGNALS) {
- write(fds[1], "", 1);
+ ignore(write(fds[1], "", 1));
signaled[signr] = true;
}
}
return xmemdup0(file_name, len);
}
}
+
+/* Pass a value to this function if it is marked with
+ * __attribute__((warn_unused_result)) and you genuinely want to ignore
+ * its return value. (Note that every scalar type can be implicitly
+ * converted to bool.) */
+void ignore(bool x UNUSED) { }
char *dir_name(const char *file_name);
+void ignore(bool x UNUSED);
+
#ifdef __cplusplus
}
#endif
static void
sigchld_handler(int signr UNUSED)
{
- write(signal_fds[1], "", 1);
+ ignore(write(signal_fds[1], "", 1));
}
int
/* Remove any partially written data, ignoring errors since there is
* nothing further we can do. */
- ftruncate(fileno(file->stream), file->offset);
+ ignore(ftruncate(fileno(file->stream), file->offset));
goto error;
}
unixctl_command_register("exit", ovsdb_server_exit, &exiting);
if (do_chdir) {
- chdir("/");
+ ignore(chdir("/"));
}
exiting = false;
fd = fpv_accept(&fpv);
fpv_destroy(&fpv);
- write(fd, out, out_size);
+ assert(write(fd, out, out_size) == out_size);
assert(!set_nonblocking(fd));