]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
depmod: Clarify the meaning of char array "alias"
authorTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 30 Sep 2024 16:54:54 +0000 (18:54 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 1 Oct 2024 14:29:30 +0000 (09:29 -0500)
It is meant as a backing buffer for scratch buffer. Do not use it
directly when constructing strings.

Co-authored-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/166
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/depmod.c

index 3117b78eeaf730e0946fc3c5106cd93f89003d74..9461dddd2bd0aa13c2fc5c8c54a1a513ad0105f2 100644 (file)
@@ -2307,10 +2307,10 @@ static int output_symbols(struct depmod *depmod, FILE *out)
 static int output_symbols_bin(struct depmod *depmod, FILE *out)
 {
        struct index_node *idx;
-       char alias[1024];
+       char aliasbuf[1024] = "symbol:";
        _cleanup_(scratchbuf_release) struct scratchbuf salias =
-               SCRATCHBUF_INITIALIZER(alias);
-       size_t baselen = sizeof("symbol:") - 1;
+               SCRATCHBUF_INITIALIZER(aliasbuf);
+       const size_t baselen = sizeof("symbol:") - 1;
        struct hash_iter iter;
        const void *v;
        int ret = 0;
@@ -2322,8 +2322,6 @@ static int output_symbols_bin(struct depmod *depmod, FILE *out)
        if (idx == NULL)
                return -ENOMEM;
 
-       memcpy(alias, "symbol:", baselen);
-
        hash_iter_init(depmod->symbols, &iter);
 
        while (hash_iter_next(&iter, NULL, &v)) {