]> git.ipfire.org Git - pakfire.git/commitdiff
repo: Improve return code handling
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Oct 2024 00:07:38 +0000 (00:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Oct 2024 00:07:38 +0000 (00:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/repo.c

index 82e845e795772203f3ce3da4fda16845eaf4d625..d47606a449925cb322f1bf31a6d033d55f5f6c9d 100644 (file)
@@ -1306,10 +1306,8 @@ int pakfire_repo_add(struct pakfire_repo* repo, const char* path,
        int r;
 
        // This operation is only supported for the command line repository
-       if (!pakfire_repo_is_commandline(repo)) {
-               errno = ENOTSUP;
-               return 1;
-       }
+       if (!pakfire_repo_is_commandline(repo))
+               return -ENOTSUP;
 
        // Download the package if we got given a URL
        if (pakfire_string_is_url(path)) {
@@ -1322,17 +1320,17 @@ int pakfire_repo_add(struct pakfire_repo* repo, const char* path,
 
        // Try to open the archive
        r = pakfire_archive_open(&archive, repo->pakfire, path);
-       if (r)
+       if (r < 0)
                goto ERROR;
 
        // Add it to this repository
        r = pakfire_repo_add_archive(repo, archive, package);
-       if (r)
+       if (r < 0)
                goto ERROR;
 
        const char* nevra = pakfire_package_get_string(*package, PAKFIRE_PKG_NEVRA);
        if (!nevra) {
-               r = 1;
+               r = -errno;
                goto ERROR;
        }