From nobody Wed Nov 27 21:11:50 2024 X-Original-To: standards@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XzBvp2wDJz5fn93 for ; Wed, 27 Nov 2024 21:11:50 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XzBvp141tz4PFC for ; Wed, 27 Nov 2024 21:11:50 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732741910; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=utj9288lVitOmn6Yo/ov2+J2Td7O9Eg67rMXQmET7hA=; b=nXTbNi/9OOPSWjpvktX2BL+6X8kIOE82YHrhaLavXWqNG80VmVKzk2rDaEdQYWUCvczFTR oEEgUX2Fm/1qv5uKZrGp/QzqFqZ5npgN188jOCh4vRA2g5fKFrD8TKKkdFoC+FYyEX5mYD xKxSLUxCX3YazHy3cR56o490R/AXLt7Tv6v/vYR3W0MzoB1MkFqI5gk1GGJQ7+XN020eaz ROF0Hr7s7wn0lxse5BYEdiYZ3Jncnt5nduhdUxmI3JcFypX59cJes+qwBF9lNoctcTbGew yk0D0mWv5i+HVo2okcR+pEkNCB0VmgtgjOpVDrBjnuXnRm8hZ2uqVLQBaGY46w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732741910; a=rsa-sha256; cv=none; b=ETdhh2HSqHXKdl+K3safhLKLdird8D1AuU33ZQDyYhBTMsR0mQVv4xYbMMrW4jAoJAT0iC lyFthN2M1qWGxKY0HH8jQ04maGqSmfDHSsrWmq2pka8lzHYYYHbazcGuJbeO+eJ44wedoO FynvrkN9H7pds60nrwwmHBdtKmU2dTyU717vb03Pjm3uTIa/UvlWnQfFpSZ59IAqYl98LR YYP5fsSjIvaeyurRHiJOMxfkkzMrT1NdPcn3r0eQSAsPoDAvF43P+rGXA73dPhlfxNJUND R5OC3pNgzspGKTr2Ou5RmzC/7GLAUoFUhz9gPeiYqSIo46P7NKV0GUlHiXb5hQ== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XzBvp0HtGz1QMC for ; Wed, 27 Nov 2024 21:11:50 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 4ARLBnZw044977 for ; Wed, 27 Nov 2024 21:11:49 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 4ARLBn6K044976 for standards@FreeBSD.org; Wed, 27 Nov 2024 21:11:49 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: standards@FreeBSD.org Subject: [Bug 283014] POSIX issue 7: fileno should be able to fail with EBADF Date: Wed, 27 Nov 2024 21:11:50 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: standards X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: gperciva@tarsnap.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: standards@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Standards compliance List-Archive: https://lists.freebsd.org/archives/freebsd-standards List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: freebsd-standards@freebsd.org Sender: owner-freebsd-standards@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D283014 Bug ID: 283014 Summary: POSIX issue 7: fileno should be able to fail with EBADF Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: standards Assignee: standards@FreeBSD.org Reporter: gperciva@tarsnap.com Nitpicky issue. Currently, FreeBSD's fileno() does not set errno. POSIX issue 6 added an optional EBADF errno, so no problem there. Issue 7 added a mandatory EBADF: > RETURN VALUE >=20 > ... Otherwise, the value -1 shall be returned and errno set to indicate t= he error. >=20 > ERRORS > > The fileno() function shall fail if: > > [EBADF] > The stream is not associated with a file. https://pubs.opengroup.org/onlinepubs/9799919799/functions/fileno.html (Issue 8 did not alter fileno.) Code example, in case it's helpful: ``` $ cat bad-fileno.c=20 #include #include int main(void) { FILE * s; int rc; /* Get an invalid stream. */ s =3D fopen("/dev/null", "r"); fclose(s); /* Set errno to an arbitrary value. */ errno =3D 123; printf("errno: %i\n", errno); /* errno is still that arbitrary value; rc is correct. */ rc =3D fileno(s); printf("rc %i, errno: %i\n", rc, errno); } $ clang -Weverything bad-fileno.c && ./a.out=20 errno: 123 rc -1, errno: 123 $ ``` --=20 You are receiving this mail because: You are the assignee for the bug.=