Define |OPENSSL_PRINTF_FORMAT_FUNC| for format string annotations.
This centralizes the conditional logic into openssl/base.h so that it doesn't have to be repeated. The name |OPENSSL_PRINTF_FORMAT_FUNC| was chosen in anticipation of eventually defining an |OPENSSL_PRINTF_FORMAT_ARG| for MSVC-style parameter annotations. Change-Id: I273e6eddd209e696dc9f82099008c35b6d477cdb Reviewed-on: https://boringssl-review.googlesource.com/6909 Reviewed-by: David Benjamin <davidben@google.com>
This commit is contained in:
committed by
David Benjamin
parent
0687bdfc12
commit
061332f216
@@ -15,6 +15,8 @@
|
||||
#ifndef OPENSSL_HEADER_CRYPTO_TEST_FILE_TEST_H
|
||||
#define OPENSSL_HEADER_CRYPTO_TEST_FILE_TEST_H
|
||||
|
||||
#include <openssl/base.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -88,11 +90,7 @@ class FileTest {
|
||||
|
||||
// PrintLine is a variant of printf which prepends the line number and appends
|
||||
// a trailing newline.
|
||||
void PrintLine(const char *format, ...)
|
||||
#ifdef __GNUC__
|
||||
__attribute__((__format__(__printf__, 2, 3)))
|
||||
#endif
|
||||
;
|
||||
void PrintLine(const char *format, ...) OPENSSL_PRINTF_FORMAT_FUNC(2, 3);
|
||||
|
||||
unsigned start_line() const { return start_line_; }
|
||||
|
||||
|
||||
@@ -138,6 +138,15 @@ extern "C" {
|
||||
|
||||
#endif /* defined(BORINGSSL_SHARED_LIBRARY) */
|
||||
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check) \
|
||||
__attribute__((format(printf, string_index, first_to_check)))
|
||||
#else
|
||||
#define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check)
|
||||
#endif
|
||||
|
||||
|
||||
/* CRYPTO_THREADID is a dummy value. */
|
||||
typedef int CRYPTO_THREADID;
|
||||
|
||||
|
||||
@@ -312,14 +312,8 @@ OPENSSL_EXPORT void BIO_copy_next_retry(BIO *bio);
|
||||
*
|
||||
* These functions are versions of printf functions that output to a BIO rather
|
||||
* than a FILE. */
|
||||
#ifdef __GNUC__
|
||||
#define __bio_h__attr__ __attribute__
|
||||
#else
|
||||
#define __bio_h__attr__(x)
|
||||
#endif
|
||||
OPENSSL_EXPORT int BIO_printf(BIO *bio, const char *format, ...)
|
||||
__bio_h__attr__((__format__(__printf__, 2, 3)));
|
||||
#undef __bio_h__attr__
|
||||
OPENSSL_PRINTF_FORMAT_FUNC(2, 3);
|
||||
|
||||
|
||||
/* Utility functions. */
|
||||
|
||||
@@ -119,18 +119,12 @@ OPENSSL_EXPORT int OPENSSL_strncasecmp(const char *a, const char *b, size_t n);
|
||||
* These functions are either OpenSSL wrappers for standard functions (i.e.
|
||||
* |BIO_snprintf| and |BIO_vsnprintf|) which don't exist in C89, or are
|
||||
* versions of printf functions that output to a BIO rather than a FILE. */
|
||||
#ifdef __GNUC__
|
||||
#define __bio_h__attr__ __attribute__
|
||||
#else
|
||||
#define __bio_h__attr__(x)
|
||||
#endif
|
||||
OPENSSL_EXPORT int BIO_snprintf(char *buf, size_t n, const char *format, ...)
|
||||
__bio_h__attr__((__format__(__printf__, 3, 4)));
|
||||
OPENSSL_PRINTF_FORMAT_FUNC(3, 4);
|
||||
|
||||
OPENSSL_EXPORT int BIO_vsnprintf(char *buf, size_t n, const char *format,
|
||||
va_list args)
|
||||
__bio_h__attr__((__format__(__printf__, 3, 0)));
|
||||
#undef __bio_h__attr__
|
||||
OPENSSL_PRINTF_FORMAT_FUNC(3, 0);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
Reference in New Issue
Block a user