ntpclient: Initialize g_ntpc_daemon at the definition

Change-Id: I4dad2e246aca7d30092cf8a4bc8136e90668f134
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2020-02-14 17:25:33 +08:00 committed by patacongo
parent 782953ff05
commit 02a800c930

View File

@ -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;