Delete trailing '\n' character in log of ctime_r 21/216521/1
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 28 Oct 2019 01:52:03 +0000 (10:52 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 28 Oct 2019 01:52:03 +0000 (10:52 +0900)
Change-Id: I494de2e480bbc3aff092136f75d114560763f747
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
plugins/iot/display/core.c
plugins/mobile/display/core.c
plugins/tv/display/core.c
plugins/wearable/display/core.c
src/display/lock-detector.c
src/time/time-handler.c

index ff8385e..421bbbb 100644 (file)
@@ -757,6 +757,7 @@ static void print_node(int next)
        DD_LIST_FOREACH(cond_head[next], elem, n) {
                diff = difftime(now, n->time);
                ctime_r(&n->time, buf);
+               buf[strlen(buf) - 1] = 0;
 
                if (diff > LOCK_TIME_WARNING) {
                        if (diff > LOCK_TIME_WARNING * 60 && n->pid < INTERNAL_LOCK_BASE && n->broadcast_warning) {
@@ -1705,6 +1706,7 @@ void pm_history_print(int fd, int count)
                    pm_history_log[index].log_type >= PM_LOG_MAX)
                        continue;
                ctime_r(&pm_history_log[index].time, time_buf);
+               time_buf[strlen(time_buf) - 1] = 0;
                snprintf(buf, sizeof(buf), "[%3d] %15s %3d %s",
                        index,
                        history_string[pm_history_log[index].log_type],
@@ -1767,6 +1769,7 @@ void print_info(int fd)
                DD_LIST_FOREACH(cond_head[s_index], elem, t) {
                        get_pname((pid_t)t->pid, pname);
                        ctime_r(&t->time, time_buf);
+                       time_buf[strlen(time_buf) - 1] = 0;
                        snprintf(buf, sizeof(buf),
                                 " %d: [%s] locked by pid %d %s %s",
                                 i++, states[s_index].name, t->pid, pname, time_buf);
@@ -1794,6 +1797,7 @@ void save_display_log(char *path)
 
        time(&now_time);
        ctime_r(&now_time, time_buf);
+       time_buf[strlen(time_buf) - 1] = 0;
 
        fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0644);
        if (fd != -1) {
index cb6e375..11faff5 100644 (file)
@@ -766,6 +766,7 @@ static void print_node(int next)
        DD_LIST_FOREACH(cond_head[next], elem, n) {
                diff = difftime(now, n->time);
                ctime_r(&n->time, buf);
+               buf[strlen(buf) - 1] = 0;
 
                if (diff > LOCK_TIME_WARNING) {
                        if (diff > LOCK_TIME_WARNING * 60 && n->pid < INTERNAL_LOCK_BASE && n->broadcast_warning) {
@@ -1715,6 +1716,7 @@ void pm_history_print(int fd, int count)
                    pm_history_log[index].log_type >= PM_LOG_MAX)
                        continue;
                ctime_r(&pm_history_log[index].time, time_buf);
+               time_buf[strlen(time_buf) - 1] = 0;
                snprintf(buf, sizeof(buf), "[%3d] %15s %3d %s",
                        index,
                        history_string[pm_history_log[index].log_type],
@@ -1777,6 +1779,7 @@ void print_info(int fd)
                DD_LIST_FOREACH(cond_head[s_index], elem, t) {
                        get_pname((pid_t)t->pid, pname);
                        ctime_r(&t->time, time_buf);
+                       time_buf[strlen(time_buf) - 1] = 0;
                        snprintf(buf, sizeof(buf),
                                 " %d: [%s] locked by pid %d %s %s",
                                 i++, states[s_index].name, t->pid, pname, time_buf);
@@ -1804,6 +1807,7 @@ void save_display_log(char *path)
 
        time(&now_time);
        ctime_r(&now_time, time_buf);
+       time_buf[strlen(time_buf) - 1] = 0;
 
        fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0644);
        if (fd != -1) {
index a520497..7069a6e 100644 (file)
@@ -757,6 +757,7 @@ static void print_node(int next)
        DD_LIST_FOREACH(cond_head[next], elem, n) {
                diff = difftime(now, n->time);
                ctime_r(&n->time, buf);
+               buf[strlen(buf) - 1] = 0;
 
                if (diff > LOCK_TIME_WARNING) {
                        if (diff > LOCK_TIME_WARNING * 60 && n->pid < INTERNAL_LOCK_BASE && n->broadcast_warning) {
@@ -1702,6 +1703,7 @@ void pm_history_print(int fd, int count)
                    pm_history_log[index].log_type >= PM_LOG_MAX)
                        continue;
                ctime_r(&pm_history_log[index].time, time_buf);
+               time_buf[strlen(time_buf) - 1] = 0;
                snprintf(buf, sizeof(buf), "[%3d] %15s %3d %s",
                        index,
                        history_string[pm_history_log[index].log_type],
@@ -1764,6 +1766,7 @@ void print_info(int fd)
                DD_LIST_FOREACH(cond_head[s_index], elem, t) {
                        get_pname((pid_t)t->pid, pname);
                        ctime_r(&t->time, time_buf);
+                       time_buf[strlen(time_buf) - 1] = 0;
                        snprintf(buf, sizeof(buf),
                                 " %d: [%s] locked by pid %d %s %s",
                                 i++, states[s_index].name, t->pid, pname, time_buf);
@@ -1791,6 +1794,7 @@ void save_display_log(char *path)
 
        time(&now_time);
        ctime_r(&now_time, time_buf);
+       time_buf[strlen(time_buf) - 1] = 0;
 
        fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0644);
        if (fd != -1) {
index 68cc5f8..1a21d54 100644 (file)
@@ -764,6 +764,7 @@ static void print_node(int next)
        DD_LIST_FOREACH(cond_head[next], elem, n) {
                diff = difftime(now, n->time);
                ctime_r(&n->time, buf);
+               buf[strlen(buf) - 1] = 0;
 
                if (diff > LOCK_TIME_WARNING) {
                        if (diff > LOCK_TIME_WARNING * 60 && n->pid < INTERNAL_LOCK_BASE && n->broadcast_warning) {
@@ -1724,6 +1725,7 @@ void pm_history_print(int fd, int count)
                    pm_history_log[index].log_type >= PM_LOG_MAX)
                        continue;
                ctime_r(&pm_history_log[index].time, time_buf);
+               time_buf[strlen(time_buf) - 1] = 0;
                snprintf(buf, sizeof(buf), "[%3d] %15s %3d %s",
                        index,
                        history_string[pm_history_log[index].log_type],
@@ -1786,6 +1788,7 @@ void print_info(int fd)
                DD_LIST_FOREACH(cond_head[s_index], elem, t) {
                        get_pname((pid_t)t->pid, pname);
                        ctime_r(&t->time, time_buf);
+                       time_buf[strlen(time_buf) - 1] = 0;
                        snprintf(buf, sizeof(buf),
                                 " %d: [%s] locked by pid %d %s %s",
                                 i++, states[s_index].name, t->pid, pname, time_buf);
@@ -1813,6 +1816,7 @@ void save_display_log(char *path)
 
        time(&now_time);
        ctime_r(&now_time, time_buf);
+       time_buf[strlen(time_buf) - 1] = 0;
 
        fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0644);
        if (fd != -1) {
index b2fa365..bf2cf5f 100644 (file)
@@ -266,6 +266,7 @@ void print_lock_info_list(int fd)
 
        cur_time = get_time();
        ctime_r(&cur_time, cur_buf);
+       cur_buf[strlen(cur_buf) - 1] = 0;
        snprintf(buf, sizeof(buf), "current time : %s\n", cur_buf);
        ret = write(fd, buf, strlen(buf));
        if (ret < 0)
@@ -288,6 +289,7 @@ void print_lock_info_list(int fd)
 
                if (info->locktime) {
                        ctime_r(&info->locktime, lock_buf);
+                       lock_buf[strlen(lock_buf) - 1] = 0;
                        tmp = strchr(lock_buf, '\n');
                        if (!tmp)
                                continue;
@@ -295,6 +297,7 @@ void print_lock_info_list(int fd)
                }
                if (info->unlocktime) {
                        ctime_r(&info->unlocktime, unlock_buf);
+                       unlock_buf[strlen(unlock_buf) - 1] = 0;
                        tmp = strchr(unlock_buf, '\n');
                        if (!tmp)
                                continue;
index 82169e2..6ffebd1 100644 (file)
@@ -109,6 +109,7 @@ int handle_timezone(char *str)
        ts2 = localtime_r(&now, &ts);
        if (ts2) {
                asctime_r(&ts, buf);
+               buf[strlen(buf) - 1] = 0;
                _D("Current local time is %s.", buf);
        }
 
@@ -140,6 +141,7 @@ int handle_timezone(char *str)
        ts2 = localtime_r(&now, &ts);
        if (ts2) {
                asctime_r(&ts, buf);
+               buf[strlen(buf) - 1] = 0;
                _D("New local time is %s.", buf);
        }
        return 0;