general: fix compiler warning about unused results

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2022-12-14 13:47:38 +00:00
parent 5a5ea76006
commit 3b342afa95
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
4 changed files with 11 additions and 4 deletions

View File

@ -1435,7 +1435,10 @@ static bool cdbus_process_windows_root_introspect(session_t *ps, DBusMessage *ms
continue;
}
char *tmp = NULL;
asprintf(&tmp, "<node name='%#010x'/>\n", w->id);
if (asprintf(&tmp, "<node name='%#010x'/>\n", w->id) < 0) {
log_fatal("Failed to allocate memory.");
abort();
}
mstrextend(&ret, tmp);
free(tmp);
}

View File

@ -256,7 +256,7 @@ static void file_logger_write(struct log_target *tgt, const char *str, size_t le
static void file_logger_writev(struct log_target *tgt, const struct iovec *vec, int vcnt) {
auto f = (struct file_logger *)tgt;
fflush(f->f);
writev(fileno(f->f), vec, vcnt);
ssize_t _ attr_unused = writev(fileno(f->f), vec, vcnt);
}
static void file_logger_destroy(struct log_target *tgt) {

View File

@ -2560,7 +2560,11 @@ int main(int argc, char **argv) {
// Notify the parent that we are done. This might cause the parent
// to quit, so only do this after setsid()
int tmp = 1;
write(pfds[1], &tmp, sizeof tmp);
if (write(pfds[1], &tmp, sizeof tmp) != sizeof tmp) {
log_fatal("Failed to notify parent process");
ret_code = 1;
break;
}
close(pfds[1]);
// We only do this once
need_fork = false;

View File

@ -27,7 +27,7 @@ void report_allocation_failure(const char *func, const char *file, unsigned int
{.iov_base = (void *)msg2, .iov_len = sizeof(msg2) - 1},
};
writev(STDERR_FILENO, v, ARR_SIZE(v));
ssize_t _ attr_unused = writev(STDERR_FILENO, v, ARR_SIZE(v));
abort();
unreachable;