From: Karel Zak Date: Wed, 15 Oct 2025 13:15:02 +0000 (+0200) Subject: lib/configs: eliminate counter variable X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dad16046185ab4d1d6e2603919acc7b67e6f032e;p=thirdparty%2Futil-linux.git lib/configs: eliminate counter variable Remove the counter variable and return list_count_entries() directly. This simplifies the code by calculating the count only when needed (on success path) rather than tracking it throughout the function. Signed-off-by: Karel Zak --- diff --git a/lib/configs.c b/lib/configs.c index 7ecd69df6..87e17fa0c 100644 --- a/lib/configs.c +++ b/lib/configs.c @@ -228,7 +228,6 @@ int ul_configs_file_list(struct list_head *file_list, struct list_head etc_list; struct list_head run_list; struct list_head usr_list; - int counter = 0; int ret; INIT_LIST_HEAD(file_list); @@ -295,14 +294,12 @@ int ul_configs_file_list(struct list_head *file_list, } } - counter = list_count_entries(file_list); - finish: ul_configs_free_list(&etc_list); ul_configs_free_list(&run_list); ul_configs_free_list(&usr_list); - return counter; + return ret < 0 ? ret : (int) list_count_entries(file_list); } void ul_configs_free_list(struct list_head *file_list)