From e1de576c63a531bdb277ee924998ce498060b875 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Sun, 22 Dec 2024 17:24:57 +0100 Subject: [PATCH] lsmod: Simplify code Reduces cyclomatic complexity and binary size. Signed-off-by: Tobias Stoeckmann --- tools/lsmod.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tools/lsmod.c b/tools/lsmod.c index ef5a08c9..ea68d1dc 100644 --- a/tools/lsmod.c +++ b/tools/lsmod.c @@ -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);