fix svace issue 11/63011/2 accepted/tizen/ivi/20160323.010819 accepted/tizen/mobile/20160322.084240 submit/tizen/20160322.005816
authorjongmun.woo <jongmun.woo@samsung.com>
Mon, 21 Mar 2016 13:15:44 +0000 (22:15 +0900)
committerjongmun.woo <jongmun.woo@samsung.com>
Tue, 22 Mar 2016 00:55:39 +0000 (09:55 +0900)
Signed-off-by: jongmun.woo <jongmun.woo@samsung.com>
Change-Id: Iab406295a744c7bc12846b1bc4294d597e008e50

geofence-server/src/geofence_server.c
geofence-server/src/geofence_server_log.c
geofence-server/src/geofence_server_log.h

index eafbcc5..61f3562 100644 (file)
@@ -123,7 +123,7 @@ static const char *__convert_wifi_error_to_string(wifi_error_e err_type)
 void emit_proximity_using_ble(GeofenceServer *geofence_server, int fence_id, geofence_proximity_state_e state)
 {
        FUNC_ENTRANCE_SERVER;
-       g_return_val_if_fail(geofence_server, -1);
+       g_return_if_fail(geofence_server);
        GeofenceItemData *item_data = __get_item_by_fence_id(fence_id, geofence_server);
        if (item_data) {
                if (item_data->common_info.proximity_status != state) {
index c28179a..0439fa3 100644 (file)
 
 int fd = -1;
 
-struct tm *__get_current_time()
+void __get_current_time(struct tm *cur_time)
 {
        time_t now;
-       struct tm *cur_time;
        time(&now);
-       cur_time = localtime(&now);
-       return cur_time;
+       localtime_r(&now, cur_time);
 }
 
 void _init_log()
 {
-       struct tm *cur_time = __get_current_time();
+       struct tm cur_time;
        char buf[256] = { 0, };
-       /*fd = open(__GEOFENCE_LOG_FILE__,  O_RDWR | O_APPEND | O_CREAT, 0644);
-        * if (fd < 0) {
-        * LOGI_GEOFENCE("Fail to open file[%s]", __GEOFENCE_LOG_FILE__);
-        * return;
-        * } */
 
-       if (cur_time != NULL)
-               sprintf(buf, "[%02d:%02d:%02d] -- START -- \n", cur_time->tm_hour, cur_time->tm_min, cur_time->tm_sec);
+       __get_current_time(&cur_time);
+       snprintf(buf, 256, "[%02d:%02d:%02d] -- START -- \n", cur_time.tm_hour, cur_time.tm_min, cur_time.tm_sec);
        LOGI_GEOFENCE("BUF[%s]", buf);
-       /*      write(fd, buf, strlen(buf));*/
 }
 
 void _deinit_log()
 {
        if (fd < 0)
                return;
-       struct tm *cur_time = __get_current_time();
+       struct tm cur_time;
        char buf[256] = { 0, };
 
-       if (cur_time != NULL)
-               sprintf(buf, "[%02d:%02d:%02d] -- END -- \n", cur_time->tm_hour, cur_time->tm_min, cur_time->tm_sec);
+       __get_current_time(&cur_time);
+       snprintf(buf, 256, "[%02d:%02d:%02d] -- END -- \n", cur_time.tm_hour, cur_time.tm_min, cur_time.tm_sec);
        LOGI_GEOFENCE("BUF[%s]", buf);
-       /*      write(fd, buf, strlen(buf));*/
 
        close(fd);
        fd = -1;
@@ -72,12 +63,10 @@ void _print_log(const char *str)
        if (fd < 0)
                return;
        char buf[256] = { 0, };
-       struct tm *cur_time = __get_current_time();
-
-       if (cur_time != NULL)
-               sprintf(buf, "[%02d:%02d:%02d] %s\n", cur_time->tm_hour, cur_time->tm_min, cur_time->tm_sec, str);
+       struct tm cur_time;
+       __get_current_time(&cur_time);
 
+       snprintf(buf, 256, "[%02d:%02d:%02d] %s\n", cur_time.tm_hour, cur_time.tm_min, cur_time.tm_sec, str);
        LOGI_GEOFENCE("BUF %s", buf);
-       /*      write(fd, buf, strlen(buf));*/
 }
 
index 592fe66..e0c97a1 100644 (file)
 void _init_log();
 void _deinit_log();
 void _print_log(const char *str);
-struct tm *__get_current_time();
+void __get_current_time(struct tm *cur_time);
 
 #define GEOFENCE_PRINT_LOG(state)      { \
                char buf[256] = {0, }; \
-               sprintf(buf, " [%s:%d] Status[%s]", __func__, __LINE__, #state); \
+               snprintf(buf, 256, " [%s:%d] Status[%s]", __func__, __LINE__, #state); \
                _print_log(buf); \
        }
 #define GEOFENCE_PRINT_LOG_WITH_ID(state, id)  { \
                char buf[256] = {0, }; \
-               sprintf(buf, " [%s:%d] Status[%s]. ID[%d]", __func__, __LINE__, #state, id); \
+               snprintf(buf, 256, " [%s:%d] Status[%s]. ID[%d]", __func__, __LINE__, #state, id); \
                _print_log(buf); \
        }