From 754dc924663cf3096062de6cd7d2e5017e8a92fc Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 19 Dec 2013 01:37:49 -0500 Subject: [PATCH] add printf attributes to printf func This fixes build warnings when using clang: .../metrics/metrics_library.cc:235:30: warning: format string is not a string literal [-Wformat-nonliteral] format, args); ^~~~~~ BUG=None TEST=`FEATURES=test emerge-x86-alex platform2` works & doesn't warn TEST=`FEATURES=test emerge-daisyplatform2` works & doesn't warn TEST=`FEATURES=test emerge-lumpy platform2` works & doesn't warn Change-Id: I03bfffe328eb1f1742de5b3fe722209e6e91f4bc Reviewed-on: https://chromium-review.googlesource.com/180930 Reviewed-by: Chris Sosa Commit-Queue: Mike Frysinger Tested-by: Mike Frysinger --- metrics/metrics_library.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/metrics/metrics_library.h b/metrics/metrics_library.h index 9a4c59bde..4bba96dce 100644 --- a/metrics/metrics_library.h +++ b/metrics/metrics_library.h @@ -138,6 +138,10 @@ class MetricsLibrary : public MetricsLibraryInterface { // The arbitrary |format| argument covers the non-LENGTH portion of the // message. The caller is responsible to store the \0 character // between NAME and VALUE (e.g. "%s%c%d", name, '\0', value). + // + // Ideally we'd use "3, 4" here instead of "4, 5", but it seems clang/gcc + // have an implicit first arg ("this"). http://crbug.com/329356 + __attribute__((__format__(__printf__, 4, 5))) int32_t FormatChromeMessage(int32_t buffer_size, char* buffer, const char* format, ...);