1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -05:00

Greatly improve printf format-string checking.

I've added the gcc-style attribute("printf") to a lot of printf-shaped
functions in this code base that didn't have it. To make that easier,
I moved the wrapping macro into defs.h, and also enabled it if we
detect the __clang__ macro as well as __GNU__ (hence, it will be used
when building for Windows using clang-cl).

The result is that a great many format strings in the code are now
checked by the compiler, where they were previously not. This causes
build failures, which I'll fix in the next commit.
This commit is contained in:
Simon Tatham
2020-01-26 14:49:31 +00:00
parent 0a4e068ada
commit cbfba7a0e9
15 changed files with 62 additions and 56 deletions

View File

@ -1205,7 +1205,7 @@ void test(int retval, ...)
sfree(argv);
}
void filecmp(char *file1, char *file2, char *fmt, ...)
PRINTF_LIKE(3, 4) void filecmp(char *file1, char *file2, char *fmt, ...)
{
/*
* Ideally I should do file comparison myself, to maximise the
@ -1303,7 +1303,7 @@ char *get_fp(char *filename, unsigned flags)
return toret;
}
void check_fp(char *filename, char *fp, char *fmt, ...)
PRINTF_LIKE(3, 4) void check_fp(char *filename, char *fp, char *fmt, ...)
{
char *newfp;