From 4a4269824bff1f6453ba438416081780e40d49ac Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Tue, 4 Aug 2009 16:08:41 +0000 Subject: [PATCH] Add more vararg error-checking annotation This was SVN commit r7073. --- source/graphics/Unit.cpp | 2 +- source/gui/CGUI.h | 6 +++--- source/lib/code_annotation.h | 7 +++++++ source/lib/ogl.h | 2 +- source/lib/res/graphics/ogl_tex.cpp | 2 +- source/network/NetLog.h | 10 +++++----- source/ps/GameSetup/GameSetup.cpp | 2 +- source/renderer/Renderer.cpp | 4 ++-- 8 files changed, 21 insertions(+), 14 deletions(-) diff --git a/source/graphics/Unit.cpp b/source/graphics/Unit.cpp index b5797ff39b..c09cf7519f 100644 --- a/source/graphics/Unit.cpp +++ b/source/graphics/Unit.cpp @@ -34,7 +34,7 @@ CUnit::CUnit(CObjectEntry* object, CEntity* entity, CObjectManager& objectManager, const std::set& actorSelections) : m_Object(object), m_Model(object->m_Model->Clone()), m_Entity(entity), -m_ID(invalidUnitId), m_ActorSelections(actorSelections), m_PlayerID(invalidPlayerId), + m_ID(invalidUnitId), m_ActorSelections(actorSelections), m_PlayerID(invalidPlayerId), m_ObjectManager(objectManager) { m_Animation = new CUnitAnimation(*this); diff --git a/source/gui/CGUI.h b/source/gui/CGUI.h index d6c77f3770..452620530e 100644 --- a/source/gui/CGUI.h +++ b/source/gui/CGUI.h @@ -306,7 +306,7 @@ private: * * @param str Error message */ - void ReportParseError(const char *str, ...); + void ReportParseError(const char *str, ...) PRINTF_ARGS(2); /** * You input the name of the object type, and let's @@ -334,7 +334,7 @@ private: */ //-------------------------------------------------------- - /** + /* Xeromyces_* functions tree (ReadRootObjects) | @@ -346,7 +346,7 @@ private: | +-Optional Type Extensions (IGUIObject::ReadExtendedElement) TODO | - +-«object» *recursive* + +-<> *recursive* (ReadRootStyles) diff --git a/source/lib/code_annotation.h b/source/lib/code_annotation.h index 73d7daf26d..5e492dfc07 100644 --- a/source/lib/code_annotation.h +++ b/source/lib/code_annotation.h @@ -211,4 +211,11 @@ private:\ // TODO: support _Printf_format_string_ for VC9+ #endif +// annotate vararg functions that expect to end with an explicit NULL +#if GCC_VERSION +# define SENTINEL_ARG __attribute__ ((sentinel)) +#else +# define SENTINEL_ARG +#endif + #endif // #ifndef INCLUDED_CODE_ANNOTATION diff --git a/source/lib/ogl.h b/source/lib/ogl.h index 064170e60f..7361aeb7d1 100644 --- a/source/lib/ogl.h +++ b/source/lib/ogl.h @@ -107,7 +107,7 @@ extern bool ogl_HaveVersion(const char* version); * @return 0 if all are present; otherwise, the first extension in the * list that's not supported (useful for reporting errors). **/ -extern const char* ogl_HaveExtensions(int dummy, ...); +extern const char* ogl_HaveExtensions(int dummy, ...) SENTINEL_ARG; /** * get a list of all supported extensions. diff --git a/source/lib/res/graphics/ogl_tex.cpp b/source/lib/res/graphics/ogl_tex.cpp index 4837965a23..0ff0dc6fcc 100644 --- a/source/lib/res/graphics/ogl_tex.cpp +++ b/source/lib/res/graphics/ogl_tex.cpp @@ -671,7 +671,7 @@ static void detect_gl_upload_caps() { // note: we don't bother checking for GL_S3_s3tc - it is incompatible // and irrelevant (was never widespread). - have_s3tc = ogl_HaveExtensions(0, "GL_ARB_texture_compression", "GL_EXT_texture_compression_s3tc", 0) == 0; + have_s3tc = ogl_HaveExtensions(0, "GL_ARB_texture_compression", "GL_EXT_texture_compression_s3tc", NULL) == 0; } // allow app hook to make ogl_tex_override calls diff --git a/source/network/NetLog.h b/source/network/NetLog.h index c71805ed1b..63d6df48b6 100644 --- a/source/network/NetLog.h +++ b/source/network/NetLog.h @@ -435,11 +435,11 @@ public: void Error ( const CStr& message ); void Fatal ( const CStr& message ); - void DebugFormat ( const char* pFormat, ... ); - void WarnFormat ( const char* pFormat, ... ); - void InfoFormat ( const char* pFormat, ... ); - void ErrorFormat ( const char* pFormat, ... ); - void FatalFormat ( const char* pFormat, ... ); + void DebugFormat ( const char* pFormat, ... ) PRINTF_ARGS(2); + void WarnFormat ( const char* pFormat, ... ) PRINTF_ARGS(2); + void InfoFormat ( const char* pFormat, ... ) PRINTF_ARGS(2); + void ErrorFormat ( const char* pFormat, ... ) PRINTF_ARGS(2); + void FatalFormat ( const char* pFormat, ... ) PRINTF_ARGS(2); /** * Retrieves the name of the logger diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index 49f3ad8c02..16c6ff6475 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -1093,7 +1093,7 @@ void Init(const CmdLineArgs& args, int flags) "GL_EXT_draw_range_elements", "GL_ARB_texture_env_combine", "GL_ARB_texture_env_dot3", - 0); + NULL); if(missing) { wchar_t buf[500]; diff --git a/source/renderer/Renderer.cpp b/source/renderer/Renderer.cpp index 0f45cc42d0..fbaceb4166 100644 --- a/source/renderer/Renderer.cpp +++ b/source/renderer/Renderer.cpp @@ -443,13 +443,13 @@ void CRenderer::EnumCaps() if (ogl_HaveExtension("GL_SGIS_generate_mipmap")) { m_Caps.m_GenerateMipmaps=true; } - if (0 == ogl_HaveExtensions(0, "GL_ARB_shader_objects", "GL_ARB_shading_language_100", 0)) + if (0 == ogl_HaveExtensions(0, "GL_ARB_shader_objects", "GL_ARB_shading_language_100", NULL)) { if (ogl_HaveExtension("GL_ARB_vertex_shader")) m_Caps.m_VertexShader=true; } - if (0 == ogl_HaveExtensions(0, "GL_ARB_shadow", "GL_ARB_depth_texture", 0)) { + if (0 == ogl_HaveExtensions(0, "GL_ARB_shadow", "GL_ARB_depth_texture", NULL)) { // According to Delphi3d.net, all relevant graphics chips that support depth textures // (i.e. Geforce3+, Radeon9500+, even i915) also have >= 4 TMUs, so this restriction // isn't actually a restriction, and it helps with integrating depth texture