Commit 20bcb3ec authored by Mike Hommey's avatar Mike Hommey
Browse files

Bug 1745344 - Unconditionally use va_copy. r=nika

Historically, va_copy was not supported everywhere (notably, MSVC didn't
have it). That's not true anymore. We already have code such as
xpcom/base/Logging.cpp that uses it unconditionally.

Differential Revision: https://phabricator.services.mozilla.com/D133458
parent c7d9933d
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -30,18 +30,6 @@
using double_conversion::DoubleToStringConverter;
using DTSC = DoubleToStringConverter;

/*
 * Note: on some platforms va_list is defined as an array,
 * and requires array notation.
 */
#ifdef HAVE_VA_COPY
#  define VARARGS_ASSIGN(foo, bar) VA_COPY(foo, bar)
#elif defined(HAVE_VA_LIST_AS_ARRAY)
#  define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0]
#else
#  define VARARGS_ASSIGN(foo, bar) (foo) = (bar)
#endif

/*
 * Numbered Argument State
 */
@@ -654,7 +642,7 @@ static bool BuildArgArray(const char* fmt, va_list ap, NumArgStateVector& nas) {
    // earlier argument.
    MOZ_ASSERT(nas[cn].type != TYPE_UNKNOWN);

    VARARGS_ASSIGN(nas[cn].ap, ap);
    va_copy(nas[cn].ap, ap);

    switch (nas[cn].type) {
      case TYPE_SCHAR:
+1 −9
Original line number Diff line number Diff line
@@ -227,14 +227,6 @@ void NS_MakeRandomString(char* aBuf, int32_t aBufLen) {

#endif

#ifdef HAVE_VA_COPY
#  define VARARGS_ASSIGN(foo, bar) VA_COPY(foo, bar)
#elif defined(HAVE_VA_LIST_AS_ARRAY)
#  define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0]
#else
#  define VARARGS_ASSIGN(foo, bar) (foo) = (bar)
#endif

#if defined(XP_WIN)
void vprintf_stderr(const char* aFmt, va_list aArgs) {
  if (IsDebuggerPresent()) {
@@ -244,7 +236,7 @@ void vprintf_stderr(const char* aFmt, va_list aArgs) {
      auto buf = MakeUnique<char[]>(lengthNeeded);
      if (buf) {
        va_list argsCpy;
        VARARGS_ASSIGN(argsCpy, aArgs);
        va_copy(argsCpy, aArgs);
        vsnprintf(buf.get(), lengthNeeded, aFmt, argsCpy);
        buf[lengthNeeded - 1] = '\0';
        va_end(argsCpy);