From 7c305178150d5adb4b566e11f1a4bc2e5fe91c8e Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 13 Aug 2017 01:05:22 +0200 Subject: [PATCH] server: Initialize user list at compile time. This allows the removal of the "initialized" variable, and it simplifies user_list_init(). --- user_list.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/user_list.c b/user_list.c index c9d265e5..8c54ab7f 100644 --- a/user_list.c +++ b/user_list.c @@ -13,7 +13,7 @@ #include "list.h" #include "user_list.h" -static struct list_head user_list; +INITIALIZED_LIST_HEAD(user_list); /* * Fill the list of users known to para_server. @@ -104,18 +104,13 @@ err: void user_list_init(char *user_list_file) { struct user *u, *tmp; - static int initialized; - if (initialized) { - list_for_each_entry_safe(u, tmp, &user_list, node) { - list_del(&u->node); - free(u->name); - free_public_key(u->pubkey); - free(u); - } - } else - INIT_LIST_HEAD(&user_list); - initialized = 1; + list_for_each_entry_safe(u, tmp, &user_list, node) { + list_del(&u->node); + free(u->name); + free_public_key(u->pubkey); + free(u); + } populate(user_list_file); } -- 2.39.2