diff options
author | Luca Boccassi <bluca@debian.org> | 2024-11-06 14:51:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-06 14:51:10 +0100 |
commit | d99fe076b58db267b4400415c5b570eb06acb753 (patch) | |
tree | c22387b4263c23998883316408fa746002d64cb5 /src/shared/elf-util.c | |
parent | core/manager: silence false-positive warning by coverity (diff) | |
parent | use report_errno_and_exit() in src/core/exec-invoke.c (diff) | |
download | systemd-d99fe076b58db267b4400415c5b570eb06acb753.tar.xz systemd-d99fe076b58db267b4400415c5b570eb06acb753.zip |
introduce report_errno_and_exit() helper (#35028)
This is a follow for https://github.com/systemd/systemd/pull/34853. In
particular, this comment
https://github.com/systemd/systemd/pull/34853#discussion_r1825837705.
Diffstat (limited to 'src/shared/elf-util.c')
-rw-r--r-- | src/shared/elf-util.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/shared/elf-util.c b/src/shared/elf-util.c index 69439b61ef..a3ff1fd3fb 100644 --- a/src/shared/elf-util.c +++ b/src/shared/elf-util.c @@ -827,12 +827,12 @@ int parse_elf_object(int fd, const char *executable, const char *root, bool fork if (fork_disable_dump) { r = RET_NERRNO(prctl(PR_SET_DUMPABLE, 0)); if (r < 0) - goto child_fail; + report_errno_and_exit(error_pipe[1], r); } r = parse_elf(fd, executable, root, ret ? &buf : NULL, ret_package_metadata ? &package_metadata : NULL); if (r < 0) - goto child_fail; + report_errno_and_exit(error_pipe[1], r); if (buf) { size_t len = strlen(buf); @@ -853,7 +853,7 @@ int parse_elf_object(int fd, const char *executable, const char *root, bool fork if (r == -EAGAIN) log_warning("Write failed, backtrace will be truncated."); else if (r < 0) - goto child_fail; + report_errno_and_exit(error_pipe[1], r); return_pipe[1] = safe_close(return_pipe[1]); } @@ -866,10 +866,8 @@ int parse_elf_object(int fd, const char *executable, const char *root, bool fork (void) fcntl(json_pipe[1], F_SETPIPE_SZ, COREDUMP_PIPE_MAX); json_out = take_fdopen(&json_pipe[1], "w"); - if (!json_out) { - r = -errno; - goto child_fail; - } + if (!json_out) + report_errno_and_exit(error_pipe[1], -errno); r = sd_json_variant_dump(package_metadata, SD_JSON_FORMAT_FLUSH, json_out, NULL); if (r < 0) @@ -877,10 +875,6 @@ int parse_elf_object(int fd, const char *executable, const char *root, bool fork } _exit(EXIT_SUCCESS); - - child_fail: - (void) write(error_pipe[1], &r, sizeof(r)); - _exit(EXIT_FAILURE); } error_pipe[1] = safe_close(error_pipe[1]); |