From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13702 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 01:03:17 +0000 Message-ID: References: <20190201002716.GK23599@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="78247"; mail-complaints-to="usenet@blaine.gmane.org" To: musl@lists.openwall.com Original-X-From: musl-return-13718-gllmg-musl=m.gmane.org@lists.openwall.com Fri Feb 01 02:03:45 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 1gpNF8-000KDe-MQ for gllmg-musl@m.gmane.org; Fri, 01 Feb 2019 02:03:42 +0100 Original-Received: (qmail 11567 invoked by uid 550); 1 Feb 2019 01:03:39 -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 11543 invoked from network); 1 Feb 2019 01:03:39 -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=Z/dO269hM1bUWl6lpEczGgqyrh6iBbHpHrlgWZo4JR4=; b=NVzRrQjrbBlEW/IXRenX+178E0i7GqSVL1GgLCkytYNARsM7z4h5/k/P1V93wODR5c EZyeznTEBaBw7vLrUF//4ZdUI8VVOPvG9SgV57WhEgPb9v4NwW81sdAjzKZNEwUFoMYm 1OPDoe/l3I/wZtuRX2G1UyNZKgvf1e/qg4i2QZw+l6kyclonX/JuJQb8pdbFuGjh3DAm 0b2J+C1EibB+iYbBgP6YF5TKXDUBh2pVywvDNMO0l0oB3/0dYIufidG/KH8urPPvUPfT eSnAdJxKB8+koWFmCht1iPesNGpXRiSCN6QJgYCwqnaQgEfLw+DdxAsflFkqmhSjizJd i8Bw== 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=Z/dO269hM1bUWl6lpEczGgqyrh6iBbHpHrlgWZo4JR4=; b=m6me8CaktGEJYE7bYVMdel+d8JwQEZsu/VDKRnUQbDim4j+S259giMRldPpeiHVQ5F lJdz8KSvxfOxXlOWDremlyt345p0NqFkdPhjf9CY2AK49ayGace5qn6NInph653sqZxz q5aDqUIxElj8z2Fj80R3bUHtmxPfJ0gpx3anUmZXfI+AmaF7ywrm1XMXnjGiMhUSUChk TxYjBMblTUSl/1v3WRiHT+O1m5YAOOtwRhO9rzRD2fHJdQZui72EqjyL8qTRQfqjbdrX 5Xj2/pl1uBQ8Vzt5GdZzsFXIAvjAEXGckSYxAg8YOe5p4NYks+R6Nq8Yr6ACbZSOxNQt MgEw== X-Gm-Message-State: AJcUukfkSASgpA+nM7xLv5TZ2216gm6NSXzOlvqvrTgLcJk0PqoGwbab OMImqyDfxtdrdFckMUS0BLZ+nXEcrUgfp4u9I+k0v1h7 X-Google-Smtp-Source: ALg8bN7iSXVZjcG/LXKJcNRZt7TrEqkUGQrZ2OLb7xWH2kVW/MDuemMjh/dwKiRDxwDuXOTVYTtXLIj9p6qcPnHmLu0= X-Received: by 2002:ac2:53b1:: with SMTP id j17mr27969611lfh.167.1548983006307; Thu, 31 Jan 2019 17:03:26 -0800 (PST) In-Reply-To: <20190201002716.GK23599@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:13702 Archived-At: On Fri, Feb 1, 2019 at 12:27 AM Rich Felker wrote: > > On Thu, Jan 31, 2019 at 09:58:06PM +0000, De Paula, Judah wrote: > > http://man7.org/linux/man-pages/man3/closedir.3.html > > Hi, > > Passing an invalid pointer to closedir is undefined behavior, and in > musl the preferred effect for undefined behavior when it's not costly > to attempt to detect is a quick crash so that the point of error in > the program can be identified and fixed. > 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. 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 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? Thanks, Jorge Almeida