]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: use strbuf_pushchars() where possible
authorEmil Velikov <emil.l.velikov@gmail.com>
Tue, 8 Oct 2024 17:04:34 +0000 (18:04 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 15 Oct 2024 14:30:59 +0000 (09:30 -0500)
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/174
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-index.c

index e1808622934e4bff859ac78ab7e93aa02097a890..4280be8d95c111ab2afa4112de54d3010f4b889e 100644 (file)
@@ -494,15 +494,10 @@ static void index_searchwild__allvalues(struct index_node_f *node,
 static void index_searchwild__all(struct index_node_f *node, int j, struct strbuf *buf,
                                  const char *subkey, struct index_value **out)
 {
-       size_t pushed = 0;
+       size_t pushed;
        int ch;
 
-       while (node->prefix[j]) {
-               ch = node->prefix[j];
-
-               pushed += strbuf_pushchar(buf, ch);
-               j++;
-       }
+       pushed = strbuf_pushchars(buf, &node->prefix[j]);
 
        for (ch = node->first; ch <= node->last; ch++) {
                struct index_node_f *child = index_readchild(node, ch);
@@ -985,15 +980,10 @@ static void index_mm_searchwild_allvalues(struct index_mm_node *node,
 static void index_mm_searchwild_all(struct index_mm_node *node, int j, struct strbuf *buf,
                                    const char *subkey, struct index_value **out)
 {
-       size_t pushed = 0;
+       size_t pushed;
        int ch;
 
-       while (node->prefix[j]) {
-               ch = node->prefix[j];
-
-               pushed += strbuf_pushchar(buf, ch);
-               j++;
-       }
+       pushed = strbuf_pushchars(buf, &node->prefix[j]);
 
        for (ch = node->first; ch <= node->last; ch++) {
                struct index_mm_node *child = index_mm_readchild(node, ch);