From dad16046185ab4d1d6e2603919acc7b67e6f032e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 15 Oct 2025 15:15:02 +0200 Subject: [PATCH] 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 --- lib/configs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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) -- 2.47.3