]> git.ipfire.org Git - pakfire.git/commitdiff
xfopen: Don't set errno when we don't fail
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 Feb 2025 17:58:03 +0000 (17:58 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 14 Feb 2025 17:07:05 +0000 (17:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/xfopen.c
tests/libpakfire/xfopen.c

index 108d44391469239ad5bdc1693601141d052be624..f1b1e54272790b9033c7ff9fa107df2463e401b2 100644 (file)
@@ -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;
 }
 
index 2ca8c929c3e6284815e5e288713822d4c555b1e8..920ad0847aa63f0c362f123135d41a7d49bb0fcd 100644 (file)
@@ -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;