Skip to content

Commit

Permalink
depmod: Clarify the meaning of char array "alias"
Browse files Browse the repository at this point in the history
It is meant as a backing buffer for scratch buffer. Do not use it
directly when constructing strings.

Co-authored-by: Lucas De Marchi <[email protected]>
Signed-off-by: Tobias Stoeckmann <[email protected]>
Link: #166
Signed-off-by: Lucas De Marchi <[email protected]>
  • Loading branch information
stoeckmann and lucasdemarchi committed Oct 1, 2024
1 parent a276fe9 commit e7db27b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions tools/depmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down

0 comments on commit e7db27b

Please sign in to comment.