From aa5a8fe28a224fd581b6053e4a5ce38f3e1a9694 Mon Sep 17 00:00:00 2001 From: rubidium42 Date: Thu, 13 May 2021 10:00:41 +0200 Subject: Codechange: use thread safe time functions Functions like localtime, gmtime and asctime are not thread safe as they (might) reuse the same buffer. So use the safer _s/_r variant for localtime and gmtime, and use strftime in favour of asctime. --- src/stdafx.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/stdafx.h') diff --git a/src/stdafx.h b/src/stdafx.h index 937c053f2..319d94edf 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -129,6 +129,7 @@ /* Warn about functions using 'printf' format syntax. First argument determines which parameter * is the format string, second argument is start of values passed to printf. */ # define WARN_FORMAT(string, args) __attribute__ ((format (printf, string, args))) +# define WARN_TIME_FORMAT(string) __attribute__ ((format (strftime, string, 0))) # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) # define FINAL final # else @@ -157,6 +158,7 @@ # define NORETURN # define CDECL # define WARN_FORMAT(string, args) +# define WARN_TIME_FORMAT(string) # define FINAL # define FALLTHROUGH # include @@ -205,6 +207,7 @@ # define CDECL _cdecl # define WARN_FORMAT(string, args) +# define WARN_TIME_FORMAT(string) # define FINAL final /* fallthrough attribute, VS 2017 */ -- cgit v1.2.3-54-g00ecf