diff options
author | James Zern <jzern@google.com> | 2021-11-02 16:29:52 -0700 |
---|---|---|
committer | James Zern <jzern@google.com> | 2021-11-02 17:21:30 -0700 |
commit | 340f60524ffa35c7324c54fe404d84cc1a1ac402 (patch) | |
tree | 5d917379528c58691a7d1f678187fd2f2ae619a0 /vpx/internal/vpx_codec_internal.h | |
parent | c56ab7d0c6f3fb215d571db3dacc0cc908c1b53c (diff) | |
download | libvpx-340f60524ffa35c7324c54fe404d84cc1a1ac402.tar libvpx-340f60524ffa35c7324c54fe404d84cc1a1ac402.tar.gz libvpx-340f60524ffa35c7324c54fe404d84cc1a1ac402.tar.bz2 libvpx-340f60524ffa35c7324c54fe404d84cc1a1ac402.zip |
vpx_codec_internal.h: add LIBVPX_FORMAT_PRINTF
and use it to set the format attribute for the printf like function
vpx_internal_error(). this allows the main library to be built with
-Wformat-nonliteral without producing warnings; the examples will be
handled in a followup.
Bug: webm:1744
Change-Id: Iebc322e24db35d902c5a2b1ed767d2e10e9c91b9
Diffstat (limited to 'vpx/internal/vpx_codec_internal.h')
-rw-r--r-- | vpx/internal/vpx_codec_internal.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/vpx/internal/vpx_codec_internal.h b/vpx/internal/vpx_codec_internal.h index 961b0bfe4..670fe380e 100644 --- a/vpx/internal/vpx_codec_internal.h +++ b/vpx/internal/vpx_codec_internal.h @@ -435,9 +435,21 @@ struct vpx_internal_error_info { #endif #endif +// Tells the compiler to perform `printf` format string checking if the +// compiler supports it; see the 'format' attribute in +// <https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html>. +#define LIBVPX_FORMAT_PRINTF(string_index, first_to_check) +#if defined(__has_attribute) +#if __has_attribute(format) +#undef LIBVPX_FORMAT_PRINTF +#define LIBVPX_FORMAT_PRINTF(string_index, first_to_check) \ + __attribute__((__format__(__printf__, string_index, first_to_check))) +#endif +#endif + void vpx_internal_error(struct vpx_internal_error_info *info, - vpx_codec_err_t error, const char *fmt, - ...) CLANG_ANALYZER_NORETURN; + vpx_codec_err_t error, const char *fmt, ...) + LIBVPX_FORMAT_PRINTF(3, 4) CLANG_ANALYZER_NORETURN; #ifdef __cplusplus } // extern "C" |