fix bug in __set_time function 51/90151/1 accepted/tizen/common/20160929.163036 accepted/tizen/ivi/20160929.081522 accepted/tizen/mobile/20160929.081527 accepted/tizen/tv/20160929.081459 accepted/tizen/wearable/20160929.081515 submit/tizen/20160929.002630
authorJiwoong Im <jiwoong.im@samsung.com>
Wed, 28 Sep 2016 13:43:25 +0000 (22:43 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Wed, 28 Sep 2016 13:43:25 +0000 (22:43 +0900)
Change-Id: I93f9d532935f831251e22fae4c9d33624e14c20a
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
alarm-manager.c

index 8258c8d..c7a7c3c 100644 (file)
@@ -269,6 +269,18 @@ int __set_time(time_t _time)
        int ret = 0;
        struct timeval tv;
        struct tm tm, *gmtime_res;
+
+       tv.tv_sec = _time;
+       tv.tv_usec = 0;
+
+       gmtime_res = gmtime_r(&(tv.tv_sec), &tm);
+       if (!gmtime_res)
+               ALARM_MGR_EXCEPTION_PRINT("gmtime_r is failed. [%d]", errno);
+
+       ret = settimeofday(&tv, NULL);
+       if (ret < 0)
+               ALARM_MGR_EXCEPTION_PRINT("settimeofday is failed.[%d]", errno);
+
 #ifdef _APPFW_FEATURE_WAKEUP_USING_RTC
        /* Using /dev/alarm, this function changes both OS time and RTC. */
        const char *rtc0 = default_rtc;
@@ -322,16 +334,6 @@ int __set_time(time_t _time)
 #else
        ALARM_MGR_LOG_PRINT("[alarm-server] RTC does not work.");
 #endif /* _APPFW_FEATURE_WAKEUP_USING_RTC */
-       tv.tv_sec = _time;
-       tv.tv_usec = 0;
-
-       gmtime_res = gmtime_r(&(tv.tv_sec), &tm);
-       if (!gmtime_res)
-               ALARM_MGR_EXCEPTION_PRINT("gmtime_r is failed. [%d]", errno);
-
-       ret = settimeofday(&tv, NULL);
-       if (ret < 0)
-               ALARM_MGR_EXCEPTION_PRINT("settimeofday is failed.[%d]", errno);
 
        return 1;
 }