зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
c7d9933da1
Коммит
20bcb3ecfe
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче