]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: Remove NOFAIL usage
authorTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 10 Sep 2024 16:53:40 +0000 (18:53 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 17 Sep 2024 03:22:39 +0000 (22:22 -0500)
Forward errors to callers instead of relying on unimplemented macro.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/123
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-index.c

index 77d43dba8a947e8ef30c5edce0b95d7760b48bef..9c9d34644bd9c34df1fe01d85eb704291cc26b2b 100644 (file)
@@ -237,7 +237,10 @@ static struct index_node_f *index_read(FILE *in, uint32_t offset)
                }
                prefix = strbuf_steal(&buf);
        } else
-               prefix = NOFAIL(strdup(""));
+               prefix = strdup("");
+
+       if (prefix == NULL)
+               goto err;
 
        if (offset & INDEX_NODE_CHILDS) {
                int first = read_char(in);
@@ -248,8 +251,10 @@ static struct index_node_f *index_read(FILE *in, uint32_t offset)
 
                child_count = last - first + 1;
 
-               node = NOFAIL(malloc(sizeof(struct index_node_f) +
-                                    sizeof(uint32_t) * child_count));
+               node = malloc(sizeof(struct index_node_f) +
+                             sizeof(uint32_t) * child_count);
+               if (node == NULL)
+                       goto err;
 
                node->first = (unsigned char) first;
                node->last = (unsigned char) last;
@@ -258,7 +263,10 @@ static struct index_node_f *index_read(FILE *in, uint32_t offset)
                        if (read_long(in, &node->children[i]) < 0)
                                goto err;
        } else {
-               node = NOFAIL(malloc(sizeof(struct index_node_f)));
+               node = malloc(sizeof(struct index_node_f));
+               if (node == NULL)
+                       goto err;
+
                node->first = INDEX_CHILDMAX;
                node->last = 0;
        }
@@ -326,7 +334,10 @@ struct index_file *index_file_open(const char *filename)
            version >> 16 != INDEX_VERSION_MAJOR)
                goto err;
 
-       new = NOFAIL(malloc(sizeof(struct index_file)));
+       new = malloc(sizeof(struct index_file));
+       if (new == NULL)
+               goto err;
+
        new->file = file;
        if (read_long(new->file, &new->root_offset) < 0)
                goto err;