From c8b649c3d2a2894807160133b1c478318a43d2aa Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 19 Feb 2025 19:19:38 +0000 Subject: [PATCH] dist: Fix return codes Signed-off-by: Michael Tremer --- src/pakfire/dist.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pakfire/dist.c b/src/pakfire/dist.c index 71ebe0601..040af3a96 100644 --- a/src/pakfire/dist.c +++ b/src/pakfire/dist.c @@ -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 -- 2.39.5