From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13704 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Jorge Almeida Newsgroups: gmane.linux.lib.musl.general Subject: Re: closedir() Date: Fri, 1 Feb 2019 09:34:50 +0000 Message-ID: References: <20190201002716.GK23599@brightrain.aerifal.cx> <20190201023007.GL23599@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="267081"; mail-complaints-to="usenet@blaine.gmane.org" To: musl@lists.openwall.com Original-X-From: musl-return-13720-gllmg-musl=m.gmane.org@lists.openwall.com Fri Feb 01 10:35:15 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1gpVEA-0017Nw-QY for gllmg-musl@m.gmane.org; Fri, 01 Feb 2019 10:35:14 +0100 Original-Received: (qmail 16335 invoked by uid 550); 1 Feb 2019 09:35:11 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 16317 invoked from network); 1 Feb 2019 09:35:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=ZykNaxuh3627ZhXkldbEzT3gSav6K8kkTi1IYH7CCWY=; b=Z88rdav/vUgNrwuJsDWshx4CR0IfWQ2fAvyXwMpK/ahurKcBd/pEOnI05tJq6/7hHB ZU6s3zZCHhkkSIwt/XGpOyjwIscOnnaRKKFUqyaPo+TUOzOkQxIf1VMIwCZnZmCZSTr0 nvsc2ra1BukQJzzdAJhfer9zE/fdnQWNcZ9Tv3hqKV+JwjchBdgcAfQR9ZWUlM9BNVKQ iNuVeTwGcAO49gZ0B93Pp3+ZpIvG3a3f8x0ni5kKvJvoGwZrtQJ17JMjZjRv90YoZVRJ hTbcQKqIhbfqMlR/7DumD1COD803fdzJy0i0l+lTGneF+/fMmCzg8gmMVlLR02chf+sl C+JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=ZykNaxuh3627ZhXkldbEzT3gSav6K8kkTi1IYH7CCWY=; b=uT0AkVrHMVmnUKKwcwJfIhdIjuOW/R96c6oAMZue8BMOxoDi4smapiYFuniK27S3QE XbGedsL/Xz+4qT4YHeOPQO1L7oVryXSN+rnOo666rJvGH1KItw7qTtBPEGo3ZI1NB8Se fKu1yyM9tclT7urYj4AD9yZWFXFv83HBX9nahrYNcGEwtijNTU4I7oUnKVnr2YyEGCnj c4/h/UPPKpvdsW6xwHwDbuuSrTwMY3BBo8Z+seFJXl42xPx+q/arfEg+c/dOfChd1nZn N+xr3rbicjlkNMPzKhkW2cfyIoxhOTfgsfjDhwcA9O5CAVPUQ4TUmS+UB5ORHdJRH2gU ONbA== X-Gm-Message-State: AJcUukcX+TVQyK2SL/6YeIMrrWaGqY3qyqCK9mCaN8v5WpooPjSqdd88 a6BJdqYPdfs+cEwLXn3rb1TEPgSoIzUvzckIrc9xO4Q9 X-Google-Smtp-Source: ALg8bN4xDqO5hbGB0YscnIobQ8OKG3Xr8DlE+/wS72XHNrjNSgAWSuxmt0o5cRKaifYjcJZmbKnfy14Avksd8BVun+k= X-Received: by 2002:a2e:568d:: with SMTP id k13-v6mr32900950lje.105.1549013699712; Fri, 01 Feb 2019 01:34:59 -0800 (PST) In-Reply-To: <20190201023007.GL23599@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:13704 Archived-At: On Fri, Feb 1, 2019 at 2:30 AM Rich Felker 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 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 >