diff options
author | smatz <smatz@openttd.org> | 2009-05-10 17:27:25 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-05-10 17:27:25 +0000 |
commit | f5316c5cbd13c3ce8c0a7d8b652ce7d975c17438 (patch) | |
tree | e9c57e3fa45a652740e681f7d25b731d7b2f9cfb /src/strgen | |
parent | 552f10bb09667a7c36724092d290808c2c9e51b4 (diff) | |
download | openttd-f5316c5cbd13c3ce8c0a7d8b652ce7d975c17438.tar.xz |
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
-Fix: wrong number of parameters or wrong parameter types sent to printf-like functions at several places
Diffstat (limited to 'src/strgen')
-rw-r--r-- | src/strgen/strgen.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index 594b778a9..9fab88b64 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -136,6 +136,8 @@ static LangString *HashFind(const char *s) # define LINE_NUM_FMT ":%d" #endif +static void CDECL strgen_warning(const char *s, ...) WARN_FORMAT(1, 2); + static void CDECL strgen_warning(const char *s, ...) { char buf[1024]; @@ -147,6 +149,8 @@ static void CDECL strgen_warning(const char *s, ...) _warnings++; } +static void CDECL strgen_error(const char *s, ...) WARN_FORMAT(1, 2); + static void CDECL strgen_error(const char *s, ...) { char buf[1024]; @@ -463,7 +467,7 @@ static const CmdStruct *ParseCommandString(const char **str, char *param, int *a cmd = FindCmd(start, s - start - 1); if (cmd == NULL) { - strgen_error("Undefined command '%.*s'", s - start - 1, start); + strgen_error("Undefined command '%.*s'", (int)(s - start - 1), start); return NULL; } @@ -600,7 +604,7 @@ static void ExtractCommandString(ParsedCommandStruct *p, const char *s, bool war p->cmd[argidx++] = ar; } else if (!(ar->flags & C_DONTCOUNT)) { // Ignore some of them - if (p->np >= lengthof(p->pairs)) error("too many commands in string, max %d", lengthof(p->pairs)); + if (p->np >= lengthof(p->pairs)) error("too many commands in string, max " PRINTF_SIZE, lengthof(p->pairs)); p->pairs[p->np].a = ar; p->pairs[p->np].v = param[0] != '\0' ? strdup(param) : ""; p->np++; @@ -734,7 +738,7 @@ static void HandleString(char *str, bool master) if (ent == NULL) { if (_strings[_next_string_id]) { - strgen_error("String ID 0x%X for '%s' already in use by '%s'", ent, str, _strings[_next_string_id]->name); + strgen_error("String ID 0x%X for '%s' already in use by '%s'", _next_string_id, str, _strings[_next_string_id]->name); return; } |