From 02a800c93098d16fa06a8b2a2ea32c3f09a3da81 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 14 Feb 2020 17:25:33 +0800 Subject: [PATCH] ntpclient: Initialize g_ntpc_daemon at the definition Change-Id: I4dad2e246aca7d30092cf8a4bc8136e90668f134 Signed-off-by: Xiang Xiao --- netutils/ntpclient/ntpclient.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/netutils/ntpclient/ntpclient.c b/netutils/ntpclient/ntpclient.c index dc8cb60df..6be13626d 100644 --- a/netutils/ntpclient/ntpclient.c +++ b/netutils/ntpclient/ntpclient.c @@ -117,7 +117,12 @@ struct ntpc_daemon_s * limitation is due only to this global data structure. */ -static struct ntpc_daemon_s g_ntpc_daemon; +static struct ntpc_daemon_s g_ntpc_daemon = +{ + NTP_NOT_RUNNING, + SEM_INITIALIZER(0), + -1 +}; /**************************************************************************** * Private Functions @@ -531,15 +536,6 @@ int ntpc_start(void) if (g_ntpc_daemon.state == NTP_NOT_RUNNING || g_ntpc_daemon.state == NTP_STOPPED) { - /* Is this the first time that the NTP daemon has been started? */ - - if (g_ntpc_daemon.state == NTP_NOT_RUNNING) - { - /* Yes... then we will need to initialize the state structure */ - - sem_init(&g_ntpc_daemon.interlock, 0, 0); - } - /* Start the NTP daemon */ g_ntpc_daemon.state = NTP_STARTED;