libbsd: Branch 'main' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 26 03:44:56 UTC 2022


 src/fpurge.c  |    2 +-
 test/fpurge.c |    4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)

New commits:
commit ba3c46b30fd45c8d2df310d89fd560c55a74eb4a
Author: Duncan Overbruck <mail at duncano.de>
Date:   Tue Jan 25 20:32:30 2022 +0100

    fpurge: Make it work with non fd based FILEs
    
    Streams opened with for example open_memstream(3) will have no associated
    file descriptor, and fileno(3) will fail.
    
    Signed-off-by: Guillem Jover <guillem at hadrons.org>

diff --git a/src/fpurge.c b/src/fpurge.c
index 462535a..350f364 100644
--- a/src/fpurge.c
+++ b/src/fpurge.c
@@ -32,7 +32,7 @@
 int
 fpurge(FILE *fp)
 {
-	if (fp == NULL || fileno(fp) < 0) {
+	if (fp == NULL) {
 		errno = EBADF;
 		return EOF;
 	}
commit 091097e0626e5cd3ba5f83da47438c88977e88bc
Author: Duncan Overbruck <mail at duncano.de>
Date:   Mon Jan 24 16:47:00 2022 +0100

    test: Remove static FILE declaration from fpurge test
    
    This does not work with libcs that do not declare the structure
    in a header file, like musl. And gets in the way of supporting
    non-fd based streams.
    
    Signed-off-by: Guillem Jover <guillem at hadrons.org>

diff --git a/test/fpurge.c b/test/fpurge.c
index a99cff7..1118f23 100644
--- a/test/fpurge.c
+++ b/test/fpurge.c
@@ -29,15 +29,11 @@
 int
 main(int argc, char *argv[])
 {
-	static FILE fp_bad;
 	FILE *fp;
 
 	if (fpurge(NULL) == 0)
 		return 1;
 
-	if (fpurge(&fp_bad) == 0)
-		return 1;
-
 	fp = fopen("/dev/zero", "r");
 	if (fpurge(fp) < 0)
 		return 1;


More information about the libbsd mailing list