qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: Vivian Wang <uwu@dram.page>
Subject: [PULL 2/5] util/getauxval: Ensure setting errno if not found
Date: Tue, 30 Jul 2024 11:11:59 +1000	[thread overview]
Message-ID: <20240730011202.480829-4-richard.henderson@linaro.org> (raw)
In-Reply-To: <20240730011202.480829-1-richard.henderson@linaro.org>

From: Vivian Wang <uwu@dram.page>

Sometimes zero is a valid value for getauxval (e.g. AT_EXECFD). Make
sure that we can distinguish between a valid zero value and a not found
entry by setting errno.

Assumes that getauxval from sys/auxv.h sets errno correctly.

Signed-off-by: Vivian Wang <uwu@dram.page>
Message-ID: <20240723100545.405476-2-uwu@dram.page>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 util/getauxval.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/util/getauxval.c b/util/getauxval.c
index b124107d61..ad4f6686a8 100644
--- a/util/getauxval.c
+++ b/util/getauxval.c
@@ -95,6 +95,7 @@ unsigned long qemu_getauxval(unsigned long type)
         }
     }
 
+    errno = ENOENT;
     return 0;
 }
 
@@ -104,7 +105,10 @@ unsigned long qemu_getauxval(unsigned long type)
 unsigned long qemu_getauxval(unsigned long type)
 {
     unsigned long aux = 0;
-    elf_aux_info(type, &aux, sizeof(aux));
+    int ret = elf_aux_info(type, &aux, sizeof(aux));
+    if (ret != 0) {
+        errno = ret;
+    }
     return aux;
 }
 
@@ -112,6 +116,7 @@ unsigned long qemu_getauxval(unsigned long type)
 
 unsigned long qemu_getauxval(unsigned long type)
 {
+    errno = ENOSYS;
     return 0;
 }
 
-- 
2.43.0



  parent reply	other threads:[~2024-07-30  2:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-30  1:11 [PULL 0/5] misc patch queue Richard Henderson
2024-07-30  1:11 ` [PULL 1/5] target/rx: Use target_ulong for address in LI Richard Henderson
2024-07-30  1:11 ` [PATCH for-9.1] tests/vm/openbsd: Install tomli Richard Henderson
2024-07-30  6:53   ` Philippe Mathieu-Daudé
2024-07-30  1:11 ` Richard Henderson [this message]
2024-07-30  1:12 ` [PULL 3/5] linux-user/main: Check errno when getting AT_EXECFD Richard Henderson
2024-07-30  1:12 ` [PULL 4/5] util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD Richard Henderson
2024-07-30  1:12 ` [PULL 5/5] linux-user: open_self_stat: Implement num_threads Richard Henderson
2024-07-30  5:31 ` [PULL 0/5] misc patch queue Richard Henderson

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=20240730011202.480829-4-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=uwu@dram.page \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).