From 905f9efbae9e1c87691bdf9a0bec469da1b135d7 Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Thu, 21 Aug 2014 02:23:30 +0000 Subject: [PATCH] Fix clang -Wformat warnings. An unsigned int was passed through %lu instead of %u (harmless on 32bit). More seriously, a wide string was passed through %s, which means only the first byte in the string got printed (since the 2nd byte is likely 0 in UCS-2). Use %ls to include the whole string, even though it might not be renderable in the target 8bit buffer. BUG=chromium:82385 R=henrike@webrtc.org Review URL: https://webrtc-codereview.appspot.com/22409004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6946 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/system_wrappers/source/trace_win.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webrtc/system_wrappers/source/trace_win.cc b/webrtc/system_wrappers/source/trace_win.cc index 129e3dd649..f1a03a5484 100644 --- a/webrtc/system_wrappers/source/trace_win.cc +++ b/webrtc/system_wrappers/source/trace_win.cc @@ -60,7 +60,7 @@ int32_t TraceWindows::AddTime(char* trace_message, dw_delta_time = 99999; } - sprintf(trace_message, "(%2u:%2u:%2u:%3u |%5lu) ", system_time.wHour, + sprintf(trace_message, "(%2u:%2u:%2u:%3u |%5u) ", system_time.wHour, system_time.wMinute, system_time.wSecond, system_time.wMilliseconds, dw_delta_time); } else { @@ -77,7 +77,7 @@ int32_t TraceWindows::AddTime(char* trace_message, if (dw_delta_time > 99999) { dw_delta_time = 99999; } - sprintf(trace_message, "(%2u:%2u:%2u:%3u |%5lu) ", system_time.wHour, + sprintf(trace_message, "(%2u:%2u:%2u:%3u |%5u) ", system_time.wHour, system_time.wMinute, system_time.wSecond, system_time.wMilliseconds, dw_delta_time); } @@ -109,7 +109,7 @@ int32_t TraceWindows::AddDateTimeInfo(char* trace_message) const { GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &sys_time, TEXT("HH':'mm':'ss"), sz_time_str, 20); - sprintf(trace_message, "Local Date: %s Local Time: %s", sz_date_str, + sprintf(trace_message, "Local Date: %ls Local Time: %ls", sz_date_str, sz_time_str); // Include NULL termination (hence + 1).