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 <kzak@redhat.com>
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);
}
}
- 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)