]> git.ipfire.org Git - pakfire.git/commitdiff
pakfire_package_get_archive: Make return value more native C
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 28 Sep 2021 12:36:25 +0000 (12:36 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 28 Sep 2021 12:36:25 +0000 (12:36 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/package.c

index 7f101987dc44618ccc69ebd86074b452b7d5d63b..e3009c3eb147290d7510cd6c3cbb27c7929a46e9 100644 (file)
@@ -1107,7 +1107,7 @@ PAKFIRE_EXPORT char* pakfire_package_dump(struct pakfire_package* pkg, int flags
 }
 
 PAKFIRE_EXPORT struct pakfire_archive* pakfire_package_get_archive(struct pakfire_package* pkg) {
-       struct pakfire_archive* archive;
+       struct pakfire_archive* archive = NULL;
 
        // Otherwise open the archive from the cache
        const char* path = pakfire_package_get_path(pkg);
@@ -1116,11 +1116,10 @@ PAKFIRE_EXPORT struct pakfire_archive* pakfire_package_get_archive(struct pakfir
 
        // Open archive
        int r = pakfire_archive_open(&archive, pkg->pakfire, path);
+       if (r)
+               return NULL;
 
-       if (r == 0)
-               return archive;
-
-       return NULL;
+       return archive;
 }
 
 static int pakfire_package_fetch_legacy_filelist(struct pakfire_package* pkg, struct pakfire_filelist* filelist) {