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
This commit is contained in:
thakis@chromium.org 2014-08-21 02:23:30 +00:00
parent add54ad770
commit 905f9efbae

View File

@ -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).