From: Lennart Poettering Date: Wed, 27 Mar 2019 13:36:36 +0000 (+0100) Subject: tree-wide: (void)ify a few unlink() and rmdir() X-Git-Tag: v242-rc1~54 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6990fb6bc6f9421a15a3e0b02909b7526cd4cbfc;p=thirdparty%2Fsystemd.git tree-wide: (void)ify a few unlink() and rmdir() Let's be helpful to static analyzers which care about whether we knowingly ignore return values. We do in these cases, since they are usually part of error paths. --- diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c index 28a1a903d12..dfd68053980 100644 --- a/src/backlight/backlight.c +++ b/src/backlight/backlight.c @@ -412,7 +412,7 @@ static int run(int argc, char *argv[]) { const char *value; if (validate_device(device) == 0) { - unlink(saved); + (void) unlink(saved); return 0; } diff --git a/src/core/namespace.c b/src/core/namespace.c index dfa3c160c1c..8475145f068 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -1674,8 +1674,8 @@ int setup_tmp_dirs(const char *id, char **tmp_dir, char **var_tmp_dir) { char *t; t = strjoina(a, "/tmp"); - rmdir(t); - rmdir(a); + (void) rmdir(t); + (void) rmdir(a); free(a); return r; diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index fbee242962f..b239d819451 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -859,7 +859,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp) error: if (temp) { - unlink(temp); + (void) unlink(temp); log_debug("Removed temporary file %s", temp); } return r; @@ -985,7 +985,7 @@ finish: if (unlink_path) { log_debug("Removed temporary file %s", path); - unlink(path); + (void) unlink(path); } return r; diff --git a/src/import/import-raw.c b/src/import/import-raw.c index 56f3431a084..b9058326035 100644 --- a/src/import/import-raw.c +++ b/src/import/import-raw.c @@ -183,7 +183,7 @@ static int raw_import_maybe_convert_qcow2(RawImport *i) { r = qcow2_convert(i->output_fd, converted_fd); if (r < 0) { - unlink(t); + (void) unlink(t); return log_error_errno(r, "Failed to convert qcow2 image: %m"); } diff --git a/src/import/pull-raw.c b/src/import/pull-raw.c index 72b9054e49c..691de8b2754 100644 --- a/src/import/pull-raw.c +++ b/src/import/pull-raw.c @@ -250,7 +250,7 @@ static int raw_pull_maybe_convert_qcow2(RawPull *i) { r = qcow2_convert(i->raw_job->disk_fd, converted_fd); if (r < 0) { - unlink(t); + (void) unlink(t); return log_error_errno(r, "Failed to convert qcow2 image: %m"); } @@ -364,7 +364,7 @@ static int raw_pull_make_local_copy(RawPull *i) { r = copy_bytes(i->raw_job->disk_fd, dfd, (uint64_t) -1, COPY_REFLINK); if (r < 0) { - unlink(tp); + (void) unlink(tp); return log_error_errno(r, "Failed to make writable copy of image: %m"); } @@ -376,7 +376,7 @@ static int raw_pull_make_local_copy(RawPull *i) { r = rename(tp, p); if (r < 0) { r = log_error_errno(errno, "Failed to move writable image into place: %m"); - unlink(tp); + (void) unlink(tp); return r; } diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index ef3556f8254..cc968252887 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -106,7 +106,7 @@ static int check_cursor_updating(Uploader *u) { if (r < 0) return log_error_errno(r, "Cannot save state to %s: %m", u->state_file); - unlink(temp_path); + (void) unlink(temp_path); return 0; } diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 42fb25cc468..00489098eee 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1841,7 +1841,7 @@ finish: safe_close(fd); if (k) { - unlink(k); + (void) unlink(k); free(k); } diff --git a/src/libsystemd/sd-hwdb/hwdb-util.c b/src/libsystemd/sd-hwdb/hwdb-util.c index 2ac4b59ad74..c83575c7c87 100644 --- a/src/libsystemd/sd-hwdb/hwdb-util.c +++ b/src/libsystemd/sd-hwdb/hwdb-util.c @@ -434,7 +434,7 @@ static int trie_store(struct trie *trie, const char *filename, bool compat) { error_fclose: r = -errno; fclose(t.f); - unlink(filename_tmp); + (void) unlink(filename_tmp); return r; } diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 1bee58db121..d427dcaa012 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -59,7 +59,7 @@ void inhibitor_free(Inhibitor *i) { free(i->why); if (i->state_file) { - unlink(i->state_file); + (void) unlink(i->state_file); free(i->state_file); } @@ -173,7 +173,7 @@ int inhibitor_stop(Inhibitor *i) { inhibit_mode_to_string(i->mode)); if (i->state_file) - unlink(i->state_file); + (void) unlink(i->state_file); i->started = false; @@ -320,7 +320,7 @@ void inhibitor_remove_fifo(Inhibitor *i) { i->fifo_fd = safe_close(i->fifo_fd); if (i->fifo_path) { - unlink(i->fifo_path); + (void) unlink(i->fifo_path); i->fifo_path = mfree(i->fifo_path); } } diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 752fcd56b1d..3e334c8d29c 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -4018,7 +4018,7 @@ int link_save(Link *link) { assert(link->manager); if (link->state == LINK_STATE_LINGER) { - unlink(link->state_file); + (void) unlink(link->state_file); return 0; } @@ -4287,7 +4287,7 @@ int link_save(Link *link) { "DHCP_LEASE=%s\n", link->lease_file); } else - unlink(link->lease_file); + (void) unlink(link->lease_file); if (link->ipv4ll) { struct in_addr address; diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index df28bcfd720..b9fa3348586 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -244,7 +244,7 @@ static int make_backup(const char *target, const char *x) { return 0; fail: - unlink(temp); + (void) unlink(temp); return r; }