From 76c53794b6202ec37f6dcace5f2ae86870e953b6 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 26 Apr 2016 11:05:26 -0700 Subject: Fix Wvarargs warning in XFA error code. Chrome has enabled the -Wvarargs warning that was added to clang, this fails with PDFium XFA builds due to two warnings: ../../xfa/fxfa/fm2js/xfa_lexer.cpp:539:16: error: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Werror,-Wvarargs] va_start(ap, msg); ^ ../../xfa/fxfa/fm2js/xfa_lexer.cpp:535:40: note: parameter of type 'XFA_FM_ERRMSG' is declared here void CXFA_FMLexer::Error(XFA_FM_ERRMSG msg, ...) { The issue is that XFA_FM_ERRMSG is an enum and we violate the promotion rules for passing the value to va_start. I removed the enum and named the flags explicitly then pass in the string as the argument. BUG=chromium:606726 Review URL: https://codereview.chromium.org/1921323002 --- xfa/fxfa/fm2js/xfa_error.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'xfa/fxfa/fm2js/xfa_error.cpp') diff --git a/xfa/fxfa/fm2js/xfa_error.cpp b/xfa/fxfa/fm2js/xfa_error.cpp index 69ce608318..020d9bc509 100644 --- a/xfa/fxfa/fm2js/xfa_error.cpp +++ b/xfa/fxfa/fm2js/xfa_error.cpp @@ -6,16 +6,12 @@ #include "xfa/fxfa/fm2js/xfa_error.h" -static const FX_WCHAR* const gs_lpStrErrorMsgInfo[] = { - L"unsupported char '%c'", L"bad suffix on number", - L"invalidate char '%c'", L"expected identifier instead of '%s'", - L"expected '%s' instead of '%s'", L"expected 'endif' instead of '%s'", - L"unexpected expression '%s'", L"expected operator '%s' instead of '%s'", - L"expected non-empty expression", -}; - -const FX_WCHAR* XFA_FM_ErrorMsg(XFA_FM_ERRMSG msg) { - if (msg < FMERR_MAXIMUM) - return gs_lpStrErrorMsgInfo[msg]; - return L""; -} +const FX_WCHAR kFMErrUnsupportedChar[] = L"unsupported char '%c'"; +const FX_WCHAR kFMErrBadSuffixNumber[] = L"bad suffix on number"; +const FX_WCHAR kFMErrExpectedIdentifier[] = + L"expected identifier instead of '%s'"; +const FX_WCHAR kFMErrExpectedToken[] = L"expected '%s' instead of '%s'"; +const FX_WCHAR kFMErrExpectedEndIf[] = L"expected 'endif' instead of '%s'"; +const FX_WCHAR kFMErrUnexpectedExpression[] = L"unexpected expression '%s'"; +const FX_WCHAR kFMErrExpectedNonEmptyExpression[] = + L"expected non-empty expression"; -- cgit v1.2.3