Add gcc-style annotations for printf-like functions.

Bug: None
Change-Id: I37a553d254cb61a882b98b14274c0fdfba039992
Reviewed-on: https://webrtc-review.googlesource.com/33002
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21281}
This commit is contained in:
Niels Möller
2017-12-14 13:30:46 +01:00
committed by Commit Bot
parent 6f772d26ce
commit 00f934abc4
4 changed files with 19 additions and 4 deletions

View File

@ -132,6 +132,9 @@ std::string ListArray(const uint16_t* array, int num_elems) {
} }
// Helper for logging SCTP messages. // Helper for logging SCTP messages.
#if defined(__GNUC__)
__attribute__((__format__(__printf__, 1, 2)))
#endif
void DebugSctpPrintf(const char* format, ...) { void DebugSctpPrintf(const char* format, ...) {
#if RTC_DCHECK_IS_ON #if RTC_DCHECK_IS_ON
char s[255]; char s[255];

View File

@ -277,6 +277,10 @@ class Logging {
void SetGlobalContext(const char* name); void SetGlobalContext(const char* name);
void SetGlobalEnable(bool enabled); void SetGlobalEnable(bool enabled);
#if defined(__GNUC__)
// Note: Implicit |this| argument counts as the first argument.
__attribute__((__format__(__printf__, 2, 3)))
#endif
void Log(const char format[], ...); void Log(const char format[], ...);
void Plot(int figure, const std::string& name, double value); void Plot(int figure, const std::string& name, double value);
void Plot(int figure, void Plot(int figure,

View File

@ -10,6 +10,8 @@
#include "modules/remote_bitrate_estimator/test/metric_recorder.h" #include "modules/remote_bitrate_estimator/test/metric_recorder.h"
#include <inttypes.h>
#include <algorithm> #include <algorithm>
#include "modules/remote_bitrate_estimator/test/packet_sender.h" #include "modules/remote_bitrate_estimator/test/packet_sender.h"
@ -321,10 +323,12 @@ void MetricRecorder::PlotDelayHistogram(const std::string& title,
// Log added latency, disregard baseline path delay. // Log added latency, disregard baseline path delay.
BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Delay average : ", BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Delay average : ",
"%lf ms", average_delay_ms - one_way_path_delay_ms); "%lf ms", average_delay_ms - one_way_path_delay_ms);
BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Delay 5th percentile : ", BWE_TEST_LOGGING_LOG1(
"%ld ms", percentile_5_ms - one_way_path_delay_ms); "RESULTS >>> " + bwe_name + " Delay 5th percentile : ", "%" PRId64 " ms",
BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Delay 95th percentile : ", percentile_5_ms - one_way_path_delay_ms);
"%ld ms", percentile_95_ms - one_way_path_delay_ms); BWE_TEST_LOGGING_LOG1(
"RESULTS >>> " + bwe_name + " Delay 95th percentile : ", "%" PRId64 " ms",
percentile_95_ms - one_way_path_delay_ms);
RTC_UNUSED(average_delay_ms); RTC_UNUSED(average_delay_ms);
RTC_UNUSED(percentile_5_ms); RTC_UNUSED(percentile_5_ms);

View File

@ -175,6 +175,10 @@ public:
void QueueString(const char* data) { void QueueString(const char* data) {
QueueData(data, strlen(data)); QueueData(data, strlen(data));
} }
#if defined(__GNUC__)
// Note: Implicit |this| argument counts as the first argument.
__attribute__((__format__(__printf__, 2, 3)))
#endif
void QueueStringF(const char* format, ...) { void QueueStringF(const char* format, ...) {
va_list args; va_list args;
va_start(args, format); va_start(args, format);