Skip to content

Commit

Permalink
Fix flags in FormatMessage, Wvarargs warning fix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jacob Abel committed Feb 4, 2014
1 parent db6f0a6 commit 6f5853b
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/OSD/OSD_FileNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
) {

Expand All @@ -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


Expand Down

0 comments on commit 6f5853b

Please sign in to comment.