Skip to content
Permalink
Browse files
Fix WTFLogVerbose variadic parameters forwarding
https://bugs.webkit.org/show_bug.cgi?id=194920

Reviewed by Alex Christensen.

WTFLogVerbose was passing the va_list to WTFLog but this function
also used variadic parameters and this is not allowed in C (that
part of the code is extern "C").

* wtf/Assertions.cpp:
(WTF::WTFLogVaList): Created to take a va_list argument instead of
variadic parameters.
(WTF::WTFLog): Kept with variadic parameters, which are
transformed to va_list and passed to WTFLogVaList.
(WTF::WTFLogVerbose): Use WTFLogVaList instead of WTFLog.


Canonical link: https://commits.webkit.org/209397@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242075 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
calvaris committed Feb 26, 2019
1 parent 01e2e86 commit 72b0143fda36cc45894cc241188734bd232f010a
Showing 2 changed files with 30 additions and 10 deletions.
@@ -1,3 +1,21 @@
2019-02-25 Xabier Rodriguez Calvar <calvaris@igalia.com>

Fix WTFLogVerbose variadic parameters forwarding
https://bugs.webkit.org/show_bug.cgi?id=194920

Reviewed by Alex Christensen.

WTFLogVerbose was passing the va_list to WTFLog but this function
also used variadic parameters and this is not allowed in C (that
part of the code is extern "C").

* wtf/Assertions.cpp:
(WTF::WTFLogVaList): Created to take a va_list argument instead of
variadic parameters.
(WTF::WTFLog): Kept with variadic parameters, which are
transformed to va_list and passed to WTFLogVaList.
(WTF::WTFLogVerbose): Use WTFLogVaList instead of WTFLog.

2019-02-25 Sam Weinig <sam@webkit.org>

Update double-conversion to the latest version
@@ -430,30 +430,22 @@ void WTFLogWithLevel(WTFLogChannel* channel, WTFLogLevel level, const char* form
va_end(args);
}

void WTFLog(WTFLogChannel* channel, const char* format, ...)
static void WTFLogVaList(WTFLogChannel* channel, const char* format, va_list args)
{
if (channel->state == WTFLogChannelOff)
return;

if (channel->state == WTFLogChannelOn) {
va_list args;
va_start(args, format);
vprintf_stderr_with_trailing_newline(format, args);
va_end(args);
return;
}

ASSERT(channel->state == WTFLogChannelOnWithAccumulation);

va_list args;
va_start(args, format);

ALLOW_NONLITERAL_FORMAT_BEGIN
String loggingString = WTF::createWithFormatAndArguments(format, args);
ALLOW_NONLITERAL_FORMAT_END

va_end(args);

if (!loggingString.endsWith('\n'))
loggingString.append('\n');

@@ -462,6 +454,16 @@ void WTFLog(WTFLogChannel* channel, const char* format, ...)
logToStderr(loggingString.utf8().data());
}

void WTFLog(WTFLogChannel* channel, const char* format, ...)
{
va_list args;
va_start(args, format);

WTFLogVaList(channel, format, args);

va_end(args);
}

void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChannel* channel, const char* format, ...)
{
if (channel->state != WTFLogChannelOn)
@@ -471,7 +473,7 @@ void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChann
va_start(args, format);

ALLOW_NONLITERAL_FORMAT_BEGIN
WTFLog(channel, format, args);
WTFLogVaList(channel, format, args);
ALLOW_NONLITERAL_FORMAT_END

va_end(args);

0 comments on commit 72b0143

Please sign in to comment.