[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 38/41] linux-user/elfload: Use Error for load_elf_interp
From: |
Peter Maydell |
Subject: |
[PULL 38/41] linux-user/elfload: Use Error for load_elf_interp |
Date: |
Tue, 20 Oct 2020 16:56:53 +0100 |
From: Richard Henderson <richard.henderson@linaro.org>
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>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20201016184207.786698-10-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@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 56fbda93d02..04c04bc2602 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.20.1
- [PULL 26/41] target/arm: Implement v8.1M low-overhead-loop instructions, (continued)
- [PULL 26/41] target/arm: Implement v8.1M low-overhead-loop instructions, Peter Maydell, 2020/10/20
- [PULL 27/41] target/arm: Fix has_vfp/has_neon ID reg squashing for M-profile, Peter Maydell, 2020/10/20
- [PULL 28/41] target/arm: Allow M-profile CPUs with FP16 to set FPSCR.FP16, Peter Maydell, 2020/10/20
- [PULL 31/41] linux-user: Set PAGE_TARGET_1 for TARGET_PROT_BTI, Peter Maydell, 2020/10/20
- [PULL 29/41] target/arm: Implement FPSCR.LTPSIZE for M-profile LOB extension, Peter Maydell, 2020/10/20
- [PULL 30/41] linux-user/aarch64: Reset btype for signals, Peter Maydell, 2020/10/20
- [PULL 32/41] include/elf: Add defines related to GNU property notes for AArch64, Peter Maydell, 2020/10/20
- [PULL 33/41] linux-user/elfload: Avoid leaking interp_name using GLib memory API, Peter Maydell, 2020/10/20
- [PULL 35/41] linux-user/elfload: Adjust iteration over phdr, Peter Maydell, 2020/10/20
- [PULL 36/41] linux-user/elfload: Move PT_INTERP detection to first loop, Peter Maydell, 2020/10/20
- [PULL 38/41] linux-user/elfload: Use Error for load_elf_interp,
Peter Maydell <=
- [PULL 34/41] linux-user/elfload: Fix coding style in load_elf_image, Peter Maydell, 2020/10/20
- [PULL 37/41] linux-user/elfload: Use Error for load_elf_image, Peter Maydell, 2020/10/20
- [PULL 39/41] linux-user/elfload: Parse NT_GNU_PROPERTY_TYPE_0 notes, Peter Maydell, 2020/10/20
- [PULL 40/41] linux-user/elfload: Parse GNU_PROPERTY_AARCH64_FEATURE_1_AND, Peter Maydell, 2020/10/20
- [PULL 41/41] tests/tcg/aarch64: Add bti smoke tests, Peter Maydell, 2020/10/20
- Re: [PULL 00/41] target-arm queue, Philippe Mathieu-Daudé, 2020/10/20
- Re: [PULL 00/41] target-arm queue, no-reply, 2020/10/20