All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 09/48] linux-user/elfload: Use Error for load_elf_interp
Date: Tue, 27 Oct 2020 11:43:59 +0000	[thread overview]
Message-ID: <20201027114438.17662-10-peter.maydell@linaro.org> (raw)
In-Reply-To: <20201027114438.17662-1-peter.maydell@linaro.org>

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



  parent reply	other threads:[~2020-10-27 12:14 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 11:43 [PULL 00/48] target-arm queue Peter Maydell
2020-10-27 11:43 ` [PULL 01/48] linux-user/aarch64: Reset btype for signals Peter Maydell
2020-10-27 11:43 ` [PULL 02/48] linux-user: Set PAGE_TARGET_1 for TARGET_PROT_BTI Peter Maydell
2020-10-27 11:43 ` [PULL 03/48] include/elf: Add defines related to GNU property notes for AArch64 Peter Maydell
2020-10-27 11:43 ` [PULL 04/48] linux-user/elfload: Avoid leaking interp_name using GLib memory API Peter Maydell
2020-10-27 11:43 ` [PULL 05/48] linux-user/elfload: Fix coding style in load_elf_image Peter Maydell
2020-10-27 11:43 ` [PULL 06/48] linux-user/elfload: Adjust iteration over phdr Peter Maydell
2020-10-27 11:43 ` [PULL 07/48] linux-user/elfload: Move PT_INTERP detection to first loop Peter Maydell
2020-10-27 11:43 ` [PULL 08/48] linux-user/elfload: Use Error for load_elf_image Peter Maydell
2020-10-27 11:43 ` Peter Maydell [this message]
2020-10-27 11:44 ` [PULL 10/48] linux-user/elfload: Parse NT_GNU_PROPERTY_TYPE_0 notes Peter Maydell
2020-10-27 11:44 ` [PULL 11/48] linux-user/elfload: Parse GNU_PROPERTY_AARCH64_FEATURE_1_AND Peter Maydell
2020-10-27 11:44 ` [PULL 12/48] tests/tcg/aarch64: Add bti smoke tests Peter Maydell
2020-10-27 11:44 ` [PULL 13/48] hw/arm/highbank: Silence warnings about missing fallthrough statements Peter Maydell
2020-10-27 11:44 ` [PULL 14/48] hw/arm: fix min_cpus for xlnx-versal-virt platform Peter Maydell
2020-10-27 11:44 ` [PULL 15/48] Move npcm7xx_timer_reached_zero call out of npcm7xx_timer_pause Peter Maydell
2020-10-27 11:44 ` [PULL 16/48] hw/timer: Adding watchdog for NPCM7XX Timer Peter Maydell
2020-10-27 11:44 ` [PULL 17/48] hw/misc: Add npcm7xx random number generator Peter Maydell
2020-10-27 11:44 ` [PULL 18/48] hw/arm/npcm7xx: Add EHCI and OHCI controllers Peter Maydell
2020-10-27 11:44 ` [PULL 19/48] hw/gpio: Add GPIO model for Nuvoton NPCM7xx Peter Maydell
2020-10-27 11:44 ` [PULL 20/48] hw/arm/smmuv3: Set the restoration priority of the vSMMUv3 explicitly Peter Maydell
2020-10-27 11:44 ` [PULL 21/48] hw/arm/bcm2836: Restrict BCM283XInfo declaration to C source Peter Maydell
2020-10-27 11:44 ` [PULL 22/48] hw/arm/bcm2836: QOM'ify more by adding class_init() to each SoC type Peter Maydell
2020-10-27 11:44 ` [PULL 23/48] hw/arm/bcm2836: Introduce BCM283XClass::core_count Peter Maydell
2020-10-27 11:44 ` [PULL 24/48] hw/arm/bcm2836: Only provide "enabled-cpus" property to multicore SoCs Peter Maydell
2020-10-27 11:44 ` [PULL 25/48] hw/arm/bcm2836: Split out common realize() code Peter Maydell
2020-10-27 11:44 ` [PULL 26/48] hw/arm/bcm2836: Introduce the BCM2835 SoC Peter Maydell
2020-10-27 11:44 ` [PULL 27/48] hw/arm/raspi: Add the Raspberry Pi A+ machine Peter Maydell
2020-10-27 11:44 ` [PULL 28/48] hw/arm/raspi: Add the Raspberry Pi Zero machine Peter Maydell
2020-10-27 11:44 ` [PULL 29/48] hw/arm/raspi: Add the Raspberry Pi 3 model A+ Peter Maydell
2020-10-27 11:44 ` [PULL 30/48] arm/trace: Fix hex printing Peter Maydell
2020-10-27 11:44 ` [PULL 31/48] hw/core/clock: provide the VMSTATE_ARRAY_CLOCK macro Peter Maydell
2020-10-27 11:44 ` [PULL 32/48] hw/core/clock: trace clock values in Hz instead of ns Peter Maydell
2020-10-27 11:44 ` [PULL 33/48] hw/arm/raspi: fix CPRMAN base address Peter Maydell
2020-10-27 11:44 ` [PULL 34/48] hw/arm/raspi: add a skeleton implementation of the CPRMAN Peter Maydell
2020-10-27 11:44 ` [PULL 35/48] hw/misc/bcm2835_cprman: add a PLL skeleton implementation Peter Maydell
2020-10-27 11:44 ` [PULL 36/48] hw/misc/bcm2835_cprman: implement PLLs behaviour Peter Maydell
2020-10-27 11:44 ` [PULL 37/48] hw/misc/bcm2835_cprman: add a PLL channel skeleton implementation Peter Maydell
2020-10-27 11:44 ` [PULL 38/48] hw/misc/bcm2835_cprman: implement PLL channels behaviour Peter Maydell
2020-10-27 11:44 ` [PULL 39/48] hw/misc/bcm2835_cprman: add a clock mux skeleton implementation Peter Maydell
2020-10-27 11:44 ` [PULL 40/48] hw/misc/bcm2835_cprman: implement clock mux behaviour Peter Maydell
2020-10-27 11:44 ` [PULL 41/48] hw/misc/bcm2835_cprman: add the DSI0HSCK multiplexer Peter Maydell
2020-10-27 11:44 ` [PULL 42/48] hw/misc/bcm2835_cprman: add sane reset values to the registers Peter Maydell
2020-10-27 11:44 ` [PULL 43/48] hw/char/pl011: add a clock input Peter Maydell
2020-10-27 11:44 ` [PULL 44/48] hw/arm/bcm2835_peripherals: connect the UART clock Peter Maydell
2020-10-27 11:44 ` [PULL 45/48] hw/watchdog: Implement SBSA watchdog device Peter Maydell
2020-10-27 11:44 ` [PULL 46/48] hw/arm/sbsa-ref: add " Peter Maydell
2020-10-27 11:44 ` [PULL 47/48] hw/core/ptimer: Support ptimer being disabled by timer callback Peter Maydell
2020-10-27 11:44 ` [PULL 48/48] hw/timer/armv7m_systick: Rewrite to use ptimers Peter Maydell
2020-11-04 10:03   ` Andrew Jones
2020-11-04 10:11     ` Philippe Mathieu-Daudé
2020-11-04 10:26       ` Andrew Jones
2020-10-27 13:22 ` [PULL 00/48] target-arm queue no-reply
2020-10-29 14:30 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201027114438.17662-10-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.