From 64b1c70fddc8b7ef2e8f629d6e5e1749f21a0e4b Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Sat, 27 Jun 2020 09:01:31 +0100 Subject: Codechange: Add WARN_FORMAT to vseprintf and fix the cascade of warnings that followed --- src/3rdparty/squirrel/squirrel/sqcompiler.cpp | 6 +++--- src/3rdparty/squirrel/squirrel/sqvm.cpp | 2 +- src/3rdparty/squirrel/squirrel/sqvm.h | 2 +- src/misc/str.hpp | 2 +- src/saveload/saveload.h | 2 +- src/script/squirrel.hpp | 4 ++-- src/string_func.h | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/3rdparty/squirrel/squirrel/sqcompiler.cpp b/src/3rdparty/squirrel/squirrel/sqcompiler.cpp index 854d080d2..9eb71d457 100644 --- a/src/3rdparty/squirrel/squirrel/sqcompiler.cpp +++ b/src/3rdparty/squirrel/squirrel/sqcompiler.cpp @@ -65,9 +65,9 @@ public: } NORETURN static void ThrowError(void *ud, const SQChar *s) { SQCompiler *c = (SQCompiler *)ud; - c->Error(s); + c->Error("%s", s); } - NORETURN void Error(const SQChar *s, ...) + NORETURN void Error(const SQChar *s, ...) WARN_FORMAT(2, 3) { static SQChar temp[256]; va_list vl; @@ -122,7 +122,7 @@ public: } Error("expected '%s'", etypename); } - Error("expected '%c'", tok); + Error("expected '%c'", (char)tok); } } SQObjectPtr ret; diff --git a/src/3rdparty/squirrel/squirrel/sqvm.cpp b/src/3rdparty/squirrel/squirrel/sqvm.cpp index 03ffea230..ee1acbf32 100644 --- a/src/3rdparty/squirrel/squirrel/sqvm.cpp +++ b/src/3rdparty/squirrel/squirrel/sqvm.cpp @@ -94,7 +94,7 @@ bool SQVM::ARITH_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1, if(!StringCat(o1, o2, trg)) return false; } else if(!ArithMetaMethod(op,o1,o2,trg)) { - Raise_Error("arith op %c on between '%s' and '%s'",op,GetTypeName(o1),GetTypeName(o2)); return false; + Raise_Error("arith op %c on between '%s' and '%s'",(char)op,GetTypeName(o1),GetTypeName(o2)); return false; } } return true; diff --git a/src/3rdparty/squirrel/squirrel/sqvm.h b/src/3rdparty/squirrel/squirrel/sqvm.h index 97557b133..9c8e986fb 100644 --- a/src/3rdparty/squirrel/squirrel/sqvm.h +++ b/src/3rdparty/squirrel/squirrel/sqvm.h @@ -81,7 +81,7 @@ public: SQString *PrintObjVal(const SQObject &o); - void Raise_Error(const SQChar *s, ...); + void Raise_Error(const SQChar *s, ...) WARN_FORMAT(2, 3); void Raise_Error(SQObjectPtr &desc); void Raise_IdxError(const SQObject &o); void Raise_CompareError(const SQObject &o1, const SQObject &o2); diff --git a/src/misc/str.hpp b/src/misc/str.hpp index e93ce5efc..9555681df 100644 --- a/src/misc/str.hpp +++ b/src/misc/str.hpp @@ -90,7 +90,7 @@ struct CStrA : public CBlobT } /** Add formatted string (like vsprintf) at the end of existing contents. */ - int AddFormatL(const char *format, va_list args) + int AddFormatL(const char *format, va_list args) WARN_FORMAT(2, 0) { size_t addSize = max(strlen(format), 16); addSize += addSize / 2; diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index 01a074bd8..af2de1189 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -896,7 +896,7 @@ void SlObject(void *object, const SaveLoad *sld); bool SlObjectMember(void *object, const SaveLoad *sld); void NORETURN SlError(StringID string, const char *extra_msg = nullptr); void NORETURN SlErrorCorrupt(const char *msg); -void NORETURN SlErrorCorruptFmt(const char *format, ...); +void NORETURN SlErrorCorruptFmt(const char *format, ...) WARN_FORMAT(1, 2); bool SaveloadCrashWithMissingNewGRFs(); diff --git a/src/script/squirrel.hpp b/src/script/squirrel.hpp index cfe54b36e..412011ccc 100644 --- a/src/script/squirrel.hpp +++ b/src/script/squirrel.hpp @@ -63,12 +63,12 @@ protected: /** * If a user runs 'print' inside a script, this function gets the params. */ - static void PrintFunc(HSQUIRRELVM vm, const SQChar *s, ...); + static void PrintFunc(HSQUIRRELVM vm, const SQChar *s, ...) WARN_FORMAT(2, 3); /** * If an error has to be print, this function is called. */ - static void ErrorPrintFunc(HSQUIRRELVM vm, const SQChar *s, ...); + static void ErrorPrintFunc(HSQUIRRELVM vm, const SQChar *s, ...) WARN_FORMAT(2, 3); public: Squirrel(const char *APIName); diff --git a/src/string_func.h b/src/string_func.h index febdf7c2a..6c226c610 100644 --- a/src/string_func.h +++ b/src/string_func.h @@ -35,7 +35,7 @@ char *strecpy(char *dst, const char *src, const char *last); char *stredup(const char *src, const char *last = nullptr); int CDECL seprintf(char *str, const char *last, const char *format, ...) WARN_FORMAT(3, 4); -int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap); +int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap) WARN_FORMAT(3, 0); char *CDECL str_fmt(const char *str, ...) WARN_FORMAT(1, 2); -- cgit v1.2.3-70-g09d2