From: Michael Tremer Date: Mon, 10 Feb 2025 17:58:03 +0000 (+0000) Subject: xfopen: Don't set errno when we don't fail X-Git-Tag: 0.9.30~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d5ce9a52d3a62fb47dca750c92fb03e6d3394210;p=pakfire.git xfopen: Don't set errno when we don't fail Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/xfopen.c b/src/pakfire/xfopen.c index 108d4439..f1b1e542 100644 --- a/src/pakfire/xfopen.c +++ b/src/pakfire/xfopen.c @@ -117,8 +117,6 @@ FILE* pakfire_xfopen(FILE* f, const char* mode) { return c->open(f, mode); } - // Nothing seems to match - errno = ENOTSUP; return f; } diff --git a/tests/libpakfire/xfopen.c b/tests/libpakfire/xfopen.c index 2ca8c929..920ad084 100644 --- a/tests/libpakfire/xfopen.c +++ b/tests/libpakfire/xfopen.c @@ -131,8 +131,12 @@ static int test_xfopen(const struct test* t) { // Open something random f = fopen("/dev/urandom", "r"); + // We don't support writing files here ASSERT_ERRNO(pakfire_xfopen(f, "w") == NULL, ENOTSUP); + // If we don't detect a supported compression, we just return the handle + ASSERT(pakfire_xfopen(f, "r") != NULL); + // Success r = EXIT_SUCCESS;