public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Fangrui Song <maskray@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/maskray/unnest] xsysconf: Only fail on error results and errno set Date: Fri, 24 Sep 2021 20:12:21 +0000 (GMT) [thread overview] Message-ID: <20210924201221.1A3213858003@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2efca218b56b0ef32289ad448c05b8f482a2e759 commit 2efca218b56b0ef32289ad448c05b8f482a2e759 Author: Stafford Horne <shorne@gmail.com> Date: Fri Sep 24 11:29:33 2021 +0900 xsysconf: Only fail on error results and errno set When testing nptl/tst-pthread-attr-affinity-fail fails with: error: xsysconf.c:33: sysconf (83): Cannot allocate memory error: 1 test failures This happens as xsysconf checks the errno after running sysconf. Internally the sysconf request for _SC_NPROCESSORS_CONF on linux allocates memory. But there is a problem, even though malloc succeeds errno is getting set to ENOMEM. POSIX allows successful calls to clobber errno. So xsysconf just checking errno is wrong. Fix xsysconf by only failing if we have an error result and errno is set. Diff: --- support/xsysconf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/xsysconf.c b/support/xsysconf.c index 2607d3a720..fce7795417 100644 --- a/support/xsysconf.c +++ b/support/xsysconf.c @@ -29,7 +29,7 @@ xsysconf (int name) int old_errno = errno; errno = 0; long result = sysconf (name); - if (errno != 0) + if (result == -1 && errno != 0) FAIL_EXIT1 ("sysconf (%d): %m", name); errno = old_errno; return result;
reply other threads:[~2021-09-24 20:12 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210924201221.1A3213858003@sourceware.org \ --to=maskray@sourceware.org \ --cc=glibc-cvs@sourceware.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: linkBe 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).