Opened 15 years ago

Closed 15 years ago

Last modified 14 years ago

#293 closed defect (fixed)

Lots of printf format string errors

Reported by: Philip Taylor Owned by: Quentin Pradet
Priority: Should Have Milestone:
Component: Core engine Keywords:
Cc: Patch:

Description

From the annotations added in r7072:

../../../source/ps/Interact.cpp: In function ‘LibError LoadUnitUIThunk(const VfsPath&, const FileInfo&, uintptr_t)’:                                               
../../../source/ps/Interact.cpp:985: warning: too many arguments for format                                                                                        
../../../source/ps/Filesystem.cpp: In member function ‘PSRETURN CVFSFile::Load(const VfsPath&)’:                                                                   
../../../source/ps/Filesystem.cpp:60: warning: format ‘%d’ expects type ‘int’, but argument 6 has type ‘LibError’                                                  
../../../source/ps/ConfigDB.cpp: In member function ‘bool CConfigDB::Reload(EConfigNamespace)’:                                                                    
../../../source/ps/ConfigDB.cpp:287: warning: format ‘%lld’ expects type ‘long long int’, but argument 6 has type ‘LibError’                                       
../../../source/ps/XML/XMLWriter.cpp: In member function ‘bool XMLWriter_File::StoreVFS(const char*)’:
../../../source/ps/XML/XMLWriter.cpp:92: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘LibError’
../../../source/simulation/EntityTemplate.cpp: In member function ‘bool CEntityTemplate::LoadXml(const CStr8&)’:
../../../source/simulation/EntityTemplate.cpp:320: warning: use of ‘h’ length modifier with ‘s’ type character
../../../source/renderer/Renderer.cpp: In static member function ‘static CRenderer::RenderPath CRenderer::GetRenderPathByName(const CStr8&)’:
../../../source/renderer/Renderer.cpp:713: warning: use of ‘h’ length modifier with ‘s’ type character
../../../source/simulation/Technology.cpp: In member function ‘bool CTechnology::LoadElEffect(XMBElement, CXeromyces&, const CStr8&)’:
../../../source/simulation/Technology.cpp:300: warning: use of ‘h’ length modifier with ‘s’ type character
../../../source/gui/CGUI.cpp: In member function ‘void CGUI::LoadXmlFile(const std::string&)’:
../../../source/gui/CGUI.cpp:1111: warning: format ‘%s’ expects type ‘char*’, but argument 6 has type ‘PSRETURN’
../../../source/gui/CGUI.cpp: In member function ‘void CGUI::Xeromyces_ReadObject(XMBElement, CXeromyces*, IGUIObject*)’:
../../../source/gui/CGUI.cpp:1398: warning: too few arguments for format
../../../source/lib/ogl.cpp: In function ‘void dump_gl_error(GLenum)’:
../../../source/lib/ogl.cpp:276: warning: format ‘%04f’ expects type ‘double’, but argument 2 has type ‘GLenum’
../../../source/scripting/ScriptGlue.cpp: In function ‘JSBool GetBuildTimestamp(JSContext*, JSObject*, uintN, jsval*, jsval*)’:
../../../source/scripting/ScriptGlue.cpp:1070: warning: unknown conversion type character ‘w’ in format
../../../source/scripting/ScriptGlue.cpp:1070: warning: too many arguments for format
../../../source/scripting/ScriptGlue.cpp:1079: warning: unknown conversion type character ‘w’ in format
../../../source/scripting/ScriptGlue.cpp:1079: warning: too many arguments for format
../../../source/scripting/ScriptGlue.cpp: In function ‘JSBool GetTrigger(JSContext*, JSObject*, uintN, jsval*, jsval*)’:
../../../source/scripting/ScriptGlue.cpp:1381: warning: unknown conversion type character ‘w’ in format
../../../source/scripting/ScriptGlue.cpp:1381: warning: too many arguments for format
../../../source/lib/res/graphics/ogl_shader.cpp: In function ‘LibError Ogl_Shader_reload(Ogl_Shader*, const VfsPath&, Handle)’:
../../../source/lib/res/graphics/ogl_shader.cpp:157: warning: use of ‘h’ length modifier with ‘s’ type character
../../../source/lib/res/graphics/ogl_shader.cpp:173: warning: use of ‘h’ length modifier with ‘s’ type character
../../../source/lib/res/graphics/ogl_shader.cpp: In function ‘LibError do_load_shader(Ogl_Program*, const VfsPath&, Handle, const CXeromyces&, const XMBElement&)’:
../../../source/lib/res/graphics/ogl_shader.cpp:279: warning: use of ‘h’ length modifier with ‘s’ type character
../../../source/lib/res/graphics/ogl_shader.cpp:287: warning: use of ‘h’ length modifier with ‘s’ type character
../../../source/lib/res/graphics/ogl_shader.cpp:295: warning: use of ‘h’ length modifier with ‘s’ type character
../../../source/lib/res/graphics/ogl_shader.cpp: In function ‘LibError Ogl_Program_reload(Ogl_Program*, const VfsPath&, Handle)’:
../../../source/lib/res/graphics/ogl_shader.cpp:348: warning: use of ‘h’ length modifier with ‘s’ type character
../../../source/lib/res/graphics/ogl_shader.cpp:369: warning: use of ‘h’ length modifier with ‘s’ type character
../../../source/lib/res/graphics/ogl_shader.cpp:378: warning: use of ‘h’ length modifier with ‘s’ type character
../../../source/lib/res/graphics/ogl_shader.cpp:394: warning: use of ‘h’ length modifier with ‘s’ type character
../../../source/lib/res/graphics/ogl_shader.cpp:400: warning: use of ‘h’ length modifier with ‘s’ type character
../../../source/lib/sysdep/os/unix/x/x.cpp: In function ‘wchar_t* sys_clipboard_get()’:
../../../source/lib/sysdep/os/unix/x/x.cpp:173: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long unsigned int’
../../../source/lib/sysdep/os/unix/x/x.cpp:173: warning: format ‘%d’ expects type ‘int’, but argument 6 has type ‘long unsigned int’
../../../source/lib/sysdep/os/unix/x/x.cpp:184: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘Atom’
../../../source/lib/sysdep/os/unix/x/x.cpp:184: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘Atom’

Attachments (1)

printfwarnings.patch (12.1 KB ) - added by Quentin Pradet 15 years ago.
Corrected issues described above.

Download all attachments as: .zip

Change History (7)

comment:1 by Quentin Pradet, 15 years ago

Should have fixed all the printf() format errors. I followed http://trac.wildfiregames.com/wiki/Coding_Conventions#Strings for the wchar_t* strings.

There is also a removal of an unused variable in a tests, and the change of the use of a deprecated function of wxWidgets since 2.6 (I have version 2.8).

comment:2 by Quentin Pradet, 15 years ago

Forget the thing I said about wxWidgets, it was in wxJS and since it is an external dependency it's not a good idea to modify it.

comment:3 by Philip Taylor, 15 years ago

Owner: set to Quentin Pradet

(Originally commented on IRC but didn't see a response there, so reposting here.)

source/lib/ogl.cpp should probably be %04x (since the GL error codes are usually hex).

source/lib/tests/test_secure_crt.h shouldn't delete suppress since that's important on Windows. Maybe the non-Windows version of SuppressErrors should be changed to be less trivial, like adding a constructor or something (not sure if that's quite enough) so GCC doesn't complain about it being unused.

Otherwise, looks good!

by Quentin Pradet, 15 years ago

Attachment: printfwarnings.patch added

Corrected issues described above.

comment:4 by Quentin Pradet, 15 years ago

For the SuppressErrors issue, I added the constructor that removes the warning: this class was a hack from the beginning, so let's continue like this. :)

comment:5 by philip, 15 years ago

Resolution: fixed
Status: newclosed

(In [7113]) Fix #293 (Lots of printf format string errors), based on patch from Cygal

comment:6 by (none), 14 years ago

Milestone: Open Source Release

Milestone Open Source Release deleted

Note: See TracTickets for help on using tickets.