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.
This commit is contained in:
Lennart Poettering 2019-03-27 14:36:36 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent 36dbf97170
commit 6990fb6bc6
11 changed files with 18 additions and 18 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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");
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -1841,7 +1841,7 @@ finish:
safe_close(fd);
if (k) {
unlink(k);
(void) unlink(k);
free(k);
}

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -244,7 +244,7 @@ static int make_backup(const char *target, const char *x) {
return 0;
fail:
unlink(temp);
(void) unlink(temp);
return r;
}