[PATCH 6/6] git-compat-util.h: add __attribute__((printf)) to git_*printf*
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jul 10, 2021, 08:47 UTC
- Message-ID
- <patch-6.6-365c5cf50b6-20210710T084445Z-avarab@gmail.com>
- In-Reply-To
- <cover-0.6-00000000000-20210710T084445Z-avarab@gmail.com>
Add __attribute__((printf)) to the compatibility functions we use under SNPRINTF_RETURNS_BOGUS=Y.
In practice this is redundant to the compiler's default printf format checking, since we mostly (entirely?) develop and test on platforms where SNPRINTF_RETURNS_BOGUS is not set. I'm doing this mainly for consistency with other code, now we don't need to think about why this particular case is different.
See c4582f93a26 (Add compat/snprintf.c for systems that return bogus, 2008-03-05) for the commit that added these functions.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- git-compat-util.h | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/git-compat-util.h b/git-compat-util.h index dca72cba294..af098d5c932 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -788,12 +788,14 @@ FILE *git_fopen(const char*, const char*); #undef snprintf #endif #define snprintf git_snprintf +__attribute__((format (printf, 3, 4))) int git_snprintf(char *str, size_t maxsize, const char *format, ...); #ifdef vsnprintf #undef vsnprintf #endif #define vsnprintf git_vsnprintf +__attribute__((format (printf, 3, 0))) int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap); #endif
-- 2.32.0.636.g43e71d69cff