Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAKpSnpJm6zv5SN3bb+R+ABTfgCcvqdOsoZNZ71MnGjwtrDV5rQ@mail.gmail.com>
Date: Fri, 1 Feb 2019 09:34:50 +0000
From: Jorge Almeida <jjalmeida@...il.com>
To: musl@...ts.openwall.com
Subject: Re: closedir()

On Fri, Feb 1, 2019 at 2:30 AM Rich Felker <dalias@...c.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@...c.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
>

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.