From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 26 Apr 2023 23:02:18 +0000 (-0600) Subject: add gnu attributes to addtional printf like functions (#1088) X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~1^2~71 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f90160dfe1d8b05bfec4f1be976c0e5a2e39a57f;p=gpsbabel.git add gnu attributes to addtional printf like functions (#1088) * add gnu attribute for format string checks on additional functions. * silence msvc whining about unknown attributes. In c++17 unknown attributes should be ignored without causing an error. But these warnings are excessive: "warning C5030: attribute 'gnu::format' is not recognized" --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 505e306f9..664e662fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -310,7 +310,7 @@ endif() if(MSVC) target_compile_definitions(gpsbabel PRIVATE _CRT_SECURE_NO_WARNINGS) target_compile_definitions(gpsbabel PRIVATE _CRT_NONSTDC_NO_WARNINGS) - target_compile_options(gpsbabel PRIVATE /MP -wd4100 -wd4267) + target_compile_options(gpsbabel PRIVATE /MP -wd4100 -wd4267 -wd5030) endif() if(APPLE) diff --git a/defs.h b/defs.h index f2e67f490..674ead1b7 100644 --- a/defs.h +++ b/defs.h @@ -1021,7 +1021,7 @@ int str_match(const char* str, const char* match); [[gnu::format(printf, 2, 3)]] int xasprintf(char** strp, const char* fmt, ...); [[gnu::format(printf, 2, 3)]] int xasprintf(QString* strp, const char* fmt, ...); [[gnu::format(printf, 2, 3)]] int xasprintf(QScopedPointer& strp, const char* fmt, ...); -int xvasprintf(char** strp, const char* fmt, va_list ap); +[[gnu::format(printf, 2, 0)]] int xvasprintf(char** strp, const char* fmt, va_list ap); char* strupper(char* src); char* strlower(char* src); time_t mklocaltime(std::tm* time); diff --git a/gbfile.h b/gbfile.h index 24be29378..a2f7257e9 100644 --- a/gbfile.h +++ b/gbfile.h @@ -104,8 +104,8 @@ QByteArray gbfreadbuf(gbsize_t size, gbfile* file); int gbfgetc(gbfile* file); QString gbfgets(char* buf, int len, gbfile* file); -int gbvfprintf(gbfile* file, const char* format, va_list ap); -int gbfprintf(gbfile* file, const char* format, ...); +[[gnu::format(printf, 2, 0)]] int gbvfprintf(gbfile* file, const char* format, va_list ap); +[[gnu::format(printf, 2, 3)]] int gbfprintf(gbfile* file, const char* format, ...); int gbfputc(int c, gbfile* file); int gbfputs(const QString& s, gbfile* file); int gbfwrite(const void* buf, gbsize_t size, gbsize_t members, gbfile* file);