From 6f5853b91c225f098d0864dea832f8136282f52e Mon Sep 17 00:00:00 2001 From: Jacob Abel Date: Tue, 4 Feb 2014 10:44:56 -0800 Subject: [PATCH] Fix flags in FormatMessage, Wvarargs warning fix MinGW has been giving a warning about 'err is not last named argument' for the line '''va_start ( arg_ptr, err );'''; C standard says that va_start should use the last named argument with '''va_start'''. When going to fix this, I noticed the wrong flags have been supplied to FormatMessage, the '''FORMAT_MESSAGE_ARGUMENT_ARRAY''' flag is not supposed to be used with a '''va_list''' structure like it was in the code. After looking at the other places in OCE that use '''_osd_wnt_set_error''' and reading that using '''FORMAT_MESSAGE_FROM_SYSTEM''' shouldn't really be used with the optional argument list unless you're sure of the exact error and what that error message requires in terms of optional inserts, I figured I'd just neuter this function and leave out the optional arguments entirely. --- src/OSD/OSD_FileNode.cxx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/OSD/OSD_FileNode.cxx b/src/OSD/OSD_FileNode.cxx index 6afae18cd3..4247b207ea 100644 --- a/src/OSD/OSD_FileNode.cxx +++ b/src/OSD/OSD_FileNode.cxx @@ -945,16 +945,13 @@ void _osd_wnt_set_error ( OSD_Error& err, OSD_WhoAmI who, ... ) { DWORD errCode; Standard_Character buffer[ 2048 ]; - va_list arg_ptr; - - va_start ( arg_ptr, err ); errCode = GetLastError (); if ( !FormatMessage ( - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, errCode, MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ), - buffer, 2048, &arg_ptr + buffer, 2048, NULL ) ) { @@ -965,8 +962,6 @@ void _osd_wnt_set_error ( OSD_Error& err, OSD_WhoAmI who, ... ) { err.SetValue ( errCode, who, buffer ); - va_end ( arg_ptr ); - } // end _set_error