[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v11 09/12] linux-user/elfload: Use Error for load_elf_interp
From: |
Richard Henderson |
Subject: |
[PATCH v11 09/12] linux-user/elfload: Use Error for load_elf_interp |
Date: |
Fri, 16 Oct 2020 11:42:04 -0700 |
This is slightly clearer than just using strerror, though
the different forms produced by error_setg_file_open and
error_setg_errno isn't entirely convenient.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/elfload.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 56fbda93d0..04c04bc260 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2675,26 +2675,27 @@ static void load_elf_interp(const char *filename,
struct image_info *info,
char bprm_buf[BPRM_BUF_SIZE])
{
int fd, retval;
+ Error *err = NULL;
fd = open(path(filename), O_RDONLY);
if (fd < 0) {
- goto exit_perror;
+ error_setg_file_open(&err, errno, filename);
+ error_report_err(err);
+ exit(-1);
}
retval = read(fd, bprm_buf, BPRM_BUF_SIZE);
if (retval < 0) {
- goto exit_perror;
+ error_setg_errno(&err, errno, "Error reading file header");
+ error_reportf_err(err, "%s: ", filename);
+ exit(-1);
}
+
if (retval < BPRM_BUF_SIZE) {
memset(bprm_buf + retval, 0, BPRM_BUF_SIZE - retval);
}
load_elf_image(filename, fd, info, NULL, bprm_buf);
- return;
-
- exit_perror:
- fprintf(stderr, "%s: %s\n", filename, strerror(errno));
- exit(-1);
}
static int symfind(const void *s0, const void *s1)
--
2.25.1
- [PATCH v11 00/12] linux-user: User support for AArch64 BTI, Richard Henderson, 2020/10/16
- [PATCH v11 01/12] linux-user/aarch64: Reset btype for signals, Richard Henderson, 2020/10/16
- [PATCH v11 02/12] linux-user: Set PAGE_TARGET_1 for TARGET_PROT_BTI, Richard Henderson, 2020/10/16
- [PATCH v11 03/12] include/elf: Add defines related to GNU property notes for AArch64, Richard Henderson, 2020/10/16
- [PATCH v11 05/12] linux-user/elfload: Fix coding style in load_elf_image, Richard Henderson, 2020/10/16
- [PATCH v11 10/12] linux-user/elfload: Parse NT_GNU_PROPERTY_TYPE_0 notes, Richard Henderson, 2020/10/16
- [PATCH v11 06/12] linux-user/elfload: Adjust iteration over phdr, Richard Henderson, 2020/10/16
- [PATCH v11 04/12] linux-user/elfload: Avoid leaking interp_name using GLib memory API, Richard Henderson, 2020/10/16
- [PATCH v11 09/12] linux-user/elfload: Use Error for load_elf_interp,
Richard Henderson <=
- [PATCH v11 08/12] linux-user/elfload: Use Error for load_elf_image, Richard Henderson, 2020/10/16
- [PATCH v11 07/12] linux-user/elfload: Move PT_INTERP detection to first loop, Richard Henderson, 2020/10/16
- [PATCH v11 12/12] tests/tcg/aarch64: Add bti smoke tests, Richard Henderson, 2020/10/16
- [PATCH v11 11/12] linux-user/elfload: Parse GNU_PROPERTY_AARCH64_FEATURE_1_AND, Richard Henderson, 2020/10/16
- Re: [PATCH v11 00/12] linux-user: User support for AArch64 BTI, no-reply, 2020/10/16
- Re: [PATCH v11 00/12] linux-user: User support for AArch64 BTI, Peter Maydell, 2020/10/20
- Re: [PATCH v11 00/12] linux-user: User support for AArch64 BTI, Peter Maydell, 2020/10/20