]> git.ipfire.org Git - pakfire.git/commitdiff
dist: Fix return codes
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Feb 2025 19:19:38 +0000 (19:19 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Feb 2025 19:19:38 +0000 (19:19 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/dist.c

index 71ebe06014bb799717303edf70cb494f84d905aa..040af3a96d0ef68ee052f1022710c30ea2338107 100644 (file)
@@ -151,7 +151,7 @@ static int pakfire_makefile_set_defaults(struct pakfire* pakfire,
 
 int pakfire_read_makefile(struct pakfire_parser** parser, struct pakfire* pakfire,
                const char* path, struct pakfire_parser_error** error) {
-       int r = 1;
+       int r;
 
        // Fetch context
        struct pakfire_ctx* ctx = pakfire_ctx(pakfire);
@@ -163,7 +163,7 @@ int pakfire_read_makefile(struct pakfire_parser** parser, struct pakfire* pakfir
 
        // Set defaults
        r = pakfire_makefile_set_defaults(pakfire, *parser, path);
-       if (r)
+       if (r < 0)
                goto ERROR;
 
        // Find all macros
@@ -180,7 +180,7 @@ int pakfire_read_makefile(struct pakfire_parser** parser, struct pakfire* pakfir
                        break;
 
                case GLOB_NOSPACE:
-                       errno = ENOMEM;
+                       r = -ENOMEM;
                        goto ERROR;
 
                case GLOB_ABORTED:
@@ -188,6 +188,7 @@ int pakfire_read_makefile(struct pakfire_parser** parser, struct pakfire* pakfir
 
                default:
                        ERROR(ctx, "glob() returned an unhandled error: %d\n", r);
+                       r = -ENOTSUP;
                        goto ERROR;
        }
 
@@ -197,7 +198,7 @@ int pakfire_read_makefile(struct pakfire_parser** parser, struct pakfire* pakfir
        for (unsigned int i = 0; i < globmacros.gl_pathc; i++) {
                // Parse the file
                r = pakfire_parser_read_file(*parser, globmacros.gl_pathv[i], error);
-               if (r)
+               if (r < 0)
                        goto ERROR;
        }
 
@@ -205,7 +206,7 @@ int pakfire_read_makefile(struct pakfire_parser** parser, struct pakfire* pakfir
 
        // Finally, parse the makefile
        r = pakfire_parser_read_file(*parser, path, error);
-       if (r) {
+       if (r < 0) {
                ERROR(ctx, "Could not read makefile %s: %m\n", path);
                goto ERROR;
        }
@@ -463,7 +464,7 @@ int pakfire_dist(struct pakfire* pakfire, const char* path,
 
        // Load makefile
        r = pakfire_read_makefile(&makefile, pakfire, path, &error);
-       if (r) {
+       if (r < 0) {
                if (error)
                        pakfire_parser_error_unref(error);
                else