[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/48] linux-user/elfload: Use Error for load_elf_interp
From: |
Peter Maydell |
Subject: |
[PULL 09/48] linux-user/elfload: Use Error for load_elf_interp |
Date: |
Tue, 27 Oct 2020 11:43:59 +0000 |
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>
Message-id: 20201021173749.111103-10-richard.henderson@linaro.org
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.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 00/48] target-arm queue, Peter Maydell, 2020/10/27
- [PULL 01/48] linux-user/aarch64: Reset btype for signals, Peter Maydell, 2020/10/27
- [PULL 05/48] linux-user/elfload: Fix coding style in load_elf_image, Peter Maydell, 2020/10/27
- [PULL 10/48] linux-user/elfload: Parse NT_GNU_PROPERTY_TYPE_0 notes, Peter Maydell, 2020/10/27
- [PULL 08/48] linux-user/elfload: Use Error for load_elf_image, Peter Maydell, 2020/10/27
- [PULL 04/48] linux-user/elfload: Avoid leaking interp_name using GLib memory API, Peter Maydell, 2020/10/27
- [PULL 02/48] linux-user: Set PAGE_TARGET_1 for TARGET_PROT_BTI, Peter Maydell, 2020/10/27
- [PULL 09/48] linux-user/elfload: Use Error for load_elf_interp,
Peter Maydell <=
- [PULL 03/48] include/elf: Add defines related to GNU property notes for AArch64, Peter Maydell, 2020/10/27
- [PULL 06/48] linux-user/elfload: Adjust iteration over phdr, Peter Maydell, 2020/10/27
- [PULL 07/48] linux-user/elfload: Move PT_INTERP detection to first loop, Peter Maydell, 2020/10/27
- [PULL 13/48] hw/arm/highbank: Silence warnings about missing fallthrough statements, Peter Maydell, 2020/10/27
- [PULL 14/48] hw/arm: fix min_cpus for xlnx-versal-virt platform, Peter Maydell, 2020/10/27
- [PULL 15/48] Move npcm7xx_timer_reached_zero call out of npcm7xx_timer_pause, Peter Maydell, 2020/10/27
- [PULL 17/48] hw/misc: Add npcm7xx random number generator, Peter Maydell, 2020/10/27
- [PULL 16/48] hw/timer: Adding watchdog for NPCM7XX Timer., Peter Maydell, 2020/10/27
- [PULL 11/48] linux-user/elfload: Parse GNU_PROPERTY_AARCH64_FEATURE_1_AND, Peter Maydell, 2020/10/27
- [PULL 12/48] tests/tcg/aarch64: Add bti smoke tests, Peter Maydell, 2020/10/27