]> git.ipfire.org Git - pakfire.git/commitdiff
parser: Initialize r on merge
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 23 Oct 2024 12:10:34 +0000 (12:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 27 Oct 2024 11:37:24 +0000 (11:37 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parser.c

index 2f158942925b8969bce123c1fa7a67fa06ea7c42..01673c63b29204264c2da94f2f90b2ff8972d63f 100644 (file)
@@ -816,18 +816,16 @@ int pakfire_parser_merge(struct pakfire_parser* parser1, struct pakfire_parser*
        struct pakfire_parser_declaration* d = NULL;
        char* namespace = NULL;
        char* value = NULL;
-       int r;
-
-       DEBUG(parser1->ctx, "Merging parsers %p and %p\n", parser1, parser2);
+       int r = 0;
 
-       if (!parser2) {
-               errno = EINVAL;
-               return 1;
-       }
+       if (!parser1 || !parser2)
+               return -EINVAL;
 
        // Do not try to merge a parser with itself
        if (parser1 == parser2)
-               return EINVAL;
+               return -EINVAL;
+
+       DEBUG(parser1->ctx, "Merging parsers %p and %p\n", parser1, parser2);
 
        for (unsigned int i = 0; i < parser2->num_declarations; i++) {
                d = parser2->declarations[i];