diff --git a/media/sctp/sctptransport.cc b/media/sctp/sctptransport.cc index 45db6372ce..e893c03e3d 100644 --- a/media/sctp/sctptransport.cc +++ b/media/sctp/sctptransport.cc @@ -132,6 +132,9 @@ std::string ListArray(const uint16_t* array, int num_elems) { } // Helper for logging SCTP messages. +#if defined(__GNUC__) +__attribute__((__format__(__printf__, 1, 2))) +#endif void DebugSctpPrintf(const char* format, ...) { #if RTC_DCHECK_IS_ON char s[255]; diff --git a/modules/remote_bitrate_estimator/test/bwe_test_logging.h b/modules/remote_bitrate_estimator/test/bwe_test_logging.h index e375ad68fa..325beb7a1a 100644 --- a/modules/remote_bitrate_estimator/test/bwe_test_logging.h +++ b/modules/remote_bitrate_estimator/test/bwe_test_logging.h @@ -277,6 +277,10 @@ class Logging { void SetGlobalContext(const char* name); 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 Plot(int figure, const std::string& name, double value); void Plot(int figure, diff --git a/modules/remote_bitrate_estimator/test/metric_recorder.cc b/modules/remote_bitrate_estimator/test/metric_recorder.cc index eeb5efba36..612ad4ab46 100644 --- a/modules/remote_bitrate_estimator/test/metric_recorder.cc +++ b/modules/remote_bitrate_estimator/test/metric_recorder.cc @@ -10,6 +10,8 @@ #include "modules/remote_bitrate_estimator/test/metric_recorder.h" +#include + #include #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. BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Delay average : ", "%lf ms", average_delay_ms - one_way_path_delay_ms); - BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Delay 5th percentile : ", - "%ld ms", percentile_5_ms - one_way_path_delay_ms); - BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Delay 95th percentile : ", - "%ld ms", percentile_95_ms - one_way_path_delay_ms); + BWE_TEST_LOGGING_LOG1( + "RESULTS >>> " + bwe_name + " Delay 5th percentile : ", "%" PRId64 " ms", + percentile_5_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(percentile_5_ms); diff --git a/rtc_base/testutils.h b/rtc_base/testutils.h index d901f82654..9b372dcca9 100644 --- a/rtc_base/testutils.h +++ b/rtc_base/testutils.h @@ -175,6 +175,10 @@ public: void QueueString(const char* 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, ...) { va_list args; va_start(args, format);