summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2020-06-27 09:01:31 +0100
committerCharles Pigott <charlespigott@googlemail.com>2020-06-27 14:51:14 +0100
commit64b1c70fddc8b7ef2e8f629d6e5e1749f21a0e4b (patch)
treeb5bbd4c1701a1ef50892744a4d5f5f27a7f3d3ff
parent224acb78b03defd075aafec9d3340b3bc0dcedfc (diff)
downloadopenttd-64b1c70fddc8b7ef2e8f629d6e5e1749f21a0e4b.tar.xz
Codechange: Add WARN_FORMAT to vseprintf and fix the cascade of warnings that followed
-rw-r--r--src/3rdparty/squirrel/squirrel/sqcompiler.cpp6
-rw-r--r--src/3rdparty/squirrel/squirrel/sqvm.cpp2
-rw-r--r--src/3rdparty/squirrel/squirrel/sqvm.h2
-rw-r--r--src/misc/str.hpp2
-rw-r--r--src/saveload/saveload.h2
-rw-r--r--src/script/squirrel.hpp4
-rw-r--r--src/string_func.h2
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<char>
}
/** 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<size_t>(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);