From: Jorge Almeida <jjalmeida@gmail.com>
To: musl@lists.openwall.com
Subject: Re: closedir()
Date: Fri, 1 Feb 2019 09:34:50 +0000 [thread overview]
Message-ID: <CAKpSnpJm6zv5SN3bb+R+ABTfgCcvqdOsoZNZ71MnGjwtrDV5rQ@mail.gmail.com> (raw)
In-Reply-To: <20190201023007.GL23599@brightrain.aerifal.cx>
On Fri, Feb 1, 2019 at 2:30 AM Rich Felker <dalias@libc.org> wrote:
>
> On Fri, Feb 01, 2019 at 01:03:17AM +0000, Jorge Almeida wrote:
> > On Fri, Feb 1, 2019 at 12:27 AM Rich Felker <dalias@libc.org> wrote:
> > >
> >
> > Is there a standard that says it is undefined behavior? According to
> > the man page quoted by the OP, and also according to
> > http://pubs.opengroup.org/onlinepubs/007904975/functions/closedir.html,
> > it should return -1 and set errno to EBADF.
>
> That's a "may fail", not a "shall fail". The only way to impose
Indeed, there is "may" in "ERRORS", but there is "shall" in "RETURN VALUE".
> > Some of us _do_ check return codes. Getting a segfault doesn't seem
> > more helpful than a message saying which function failed and why. As
>
> You don't get a message unless you actively check the return value and
Yes, of course. But I cannot print it if the program segfaults.
> print one yourself. Most callers will not, especially since there is
Sure, but isn't that sloppy programming? I'm sure there are technical
reasons to choose a particular implementation strategy, and I don't
presume to be qualified to judge. Still, I can't help to feel
frustrated and I do think this kind of frustration should befall on
such programmers as will call a non void system function and won't
bother to check the return value.
>
> > an amateur, I'm just trying to figure out what to do when I need to
> > use a function I'm not very familiar with. Reading the manual seems
> > pointless. Can you suggest a reliable, accessible source of
> > information?
>
> The standard is the best, but your link is an outdated version. Here
> is the current one:
>
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/closedir.html
Thank you, bookmark updated.
Jorge
>
prev parent reply other threads:[~2019-02-01 9:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-31 21:58 closedir() De Paula, Judah
2019-02-01 0:27 ` closedir() Rich Felker
2019-02-01 1:03 ` closedir() Jorge Almeida
2019-02-01 2:30 ` closedir() Rich Felker
2019-02-01 9:34 ` Jorge Almeida [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=CAKpSnpJm6zv5SN3bb+R+ABTfgCcvqdOsoZNZ71MnGjwtrDV5rQ@mail.gmail.com \
--to=jjalmeida@gmail.com \
--cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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).