public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
	Yu Chien Peter Lin <peterlin@andestech.com>
Subject: Re: [PATCH] malloc: Do not clobber errno on __getrandom_nocancel (BZ#29624)
Date: Thu, 29 Sep 2022 17:52:38 +0000	[thread overview]
Message-ID: <AS4PR08MB790180F515B3FFB2D9460D8583579@AS4PR08MB7901.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <20220929164510.3454281-1-adhemerval.zanella@linaro.org>

Hi Adhemerval,

+static inline int
+__getrandom_nocancel (void *buf, size_t buflen, unsigned int flags)
+{
+  int save_errno = errno;
+  int r = __getrandom (buf, buflen, flags);
+  __set_errno (save_errno);
+  return r == -1 ? -save_errno : r;
+}

How does this work? If it fails, it returns the negated original errno, which
doesn't make any sense. It can be zero and so it would imply success on
failure... Shouldn't it just return r as it tries to preserve errno or do we need
if (r == -1) r = -errno; before we restore errno?

Cheers,
Wilco

      parent reply	other threads:[~2022-09-29 17:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29 16:45 Adhemerval Zanella
2022-09-29 17:31 ` Andreas Schwab
2022-09-29 17:46 ` Yann Droneaud
2022-09-29 17:49   ` Adhemerval Zanella Netto
2022-09-29 17:52 ` Wilco Dijkstra [this message]

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=AS4PR08MB790180F515B3FFB2D9460D8583579@AS4PR08MB7901.eurprd08.prod.outlook.com \
    --to=wilco.dijkstra@arm.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=peterlin@andestech.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).