From 1202ac303d4a195e774b9d3a6496da4b722f7327 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 7 Mar 2016 20:51:18 +0900 Subject: [PATCH] Fix Svace issue Change-Id: Ided4e6fbfea0c8caf941a1a1a5fc05b1e05d79b3 --- res/simple_debug.cpp | 7 +++++-- scl/sclcontroller.cpp | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/res/simple_debug.cpp b/res/simple_debug.cpp index d3c9fcc..2de8f76 100644 --- a/res/simple_debug.cpp +++ b/res/simple_debug.cpp @@ -83,10 +83,13 @@ SclLog::log(enum LOG_LEVEL level, char* fmt, ...) { struct tm *timenow; time(&now); - timenow = localtime(&now); + localtime_r(&now, timenow); if (timenow) { - fprintf(m_flog, "[ %s ] %s\n", log_message[level], asctime(timenow)); + char buf[64] = { 0 }; + asctime_r(timenow, buf); + + fprintf(m_flog, "[ %s ] %s\n", log_message[level], buf); fprintf(m_flog, "\t%s\n", str_log); fflush(m_flog); diff --git a/scl/sclcontroller.cpp b/scl/sclcontroller.cpp index b75771f..219dcdc 100644 --- a/scl/sclcontroller.cpp +++ b/scl/sclcontroller.cpp @@ -3515,7 +3515,9 @@ CSCLController::timer_event(const scl32 data) break; case SCL_TIMER_AUTOTEST: { srand(time(NULL)); - sclint rnd = rand() % 100; + + unsigned int seed; + sclint rnd = rand_r(&seed) % 100; const SclLayout *layout = cache->get_cur_layout(windows->get_base_window()); @@ -3523,10 +3525,10 @@ CSCLController::timer_event(const scl32 data) return FALSE; } srand(time(NULL)); - sclint x = (rand() % (layout->width)); + sclint x = (rand_r(&seed) % (layout->width)); srand(time(NULL)); - sclint y = (rand() % (layout->height)); + sclint y = (rand_r(&seed) % (layout->height)); if (rnd < 80) { events->generate_mouse_event(SCL_MOUSE_EVENT_PRESS, x, y); -- 2.7.4