Skip to content

Commit

Permalink
lsmod: Simplify code
Browse files Browse the repository at this point in the history
Reduces cyclomatic complexity and binary size.

Signed-off-by: Tobias Stoeckmann <[email protected]>
Link: #271
Signed-off-by: Lucas De Marchi <[email protected]>
  • Loading branch information
stoeckmann authored and lucasdemarchi committed Dec 22, 2024
1 parent ccc26d6 commit ad689ac
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions tools/lsmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,15 @@ static int do_lsmod(int argc, char *argv[])
int use_count = kmod_module_get_refcnt(mod);
long size = kmod_module_get_size(mod);
struct kmod_list *holders, *hitr;
int first = 1;
int sep = ' ';

printf("%-19s %8ld %d", name, size, use_count);
holders = kmod_module_get_holders(mod);
kmod_list_foreach(hitr, holders) {
struct kmod_module *hm = kmod_module_get_module(hitr);

if (!first) {
putchar(',');
} else {
putchar(' ');
first = 0;
}
putchar(sep);
sep = ',';

fputs(kmod_module_get_name(hm), stdout);
kmod_module_unref(hm);
Expand Down

0 comments on commit ad689ac

Please sign in to comment.