crash-reporter: Move disabling of GCC warning into source file
Rather than disable the "format not a string literal, argument types not
checked" warning for the entire kernel_collector.cc file, only disable it
for the code in question.
BUG=chromium-os:27127
TEST=Ran unittests
Change-Id: Id85e7945779cd5d1b6a3b68cfdedae53b3f22c74
Reviewed-on: https://gerrit.chromium.org/gerrit/20484
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Michael Krebs <mkrebs@chromium.org>
Tested-by: Michael Krebs <mkrebs@chromium.org>
diff --git a/crash_reporter/Makefile b/crash_reporter/Makefile
index 085b7de..d123a80 100644
--- a/crash_reporter/Makefile
+++ b/crash_reporter/Makefile
@@ -24,10 +24,6 @@
# -- Executable crash_reporter --
-# Disable error "format not a string literal, argument types not checked" for
-# the StringPrintf() in KernelCollector::GetRamoopsRecordPath() because it's
-# valid, but GNU apparently doesn't bother checking a const format string.
-kernel_collector.o: CXXFLAGS += -Wno-format-nonliteral
CXX_BINARY(crash_reporter): LDLIBS += -lmetrics
CXX_BINARY(crash_reporter): crash_reporter.o $(CRASH_OBJS)
@@ -36,6 +32,7 @@
# -- Executable list_proxies --
+
LIST_PROXIES_PKGS = dbus-1 dbus-glib-1
LIST_PROXIES_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(LIST_PROXIES_PKGS))
LIST_PROXIES_LIBS := $(shell $(PKG_CONFIG) --libs $(LIST_PROXIES_PKGS))
diff --git a/crash_reporter/kernel_collector.cc b/crash_reporter/kernel_collector.cc
index e15dc85..fc8500e 100644
--- a/crash_reporter/kernel_collector.cc
+++ b/crash_reporter/kernel_collector.cc
@@ -96,7 +96,13 @@
void KernelCollector::GetRamoopsRecordPath(FilePath *path,
size_t record) {
+ // Disable error "format not a string literal, argument types not checked"
+ // because this is valid, but GNU apparently doesn't bother checking a const
+ // format string.
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wformat-nonliteral"
*path = ramoops_dump_path_.Append(StringPrintf(kDumpFormat, record));
+ #pragma GCC diagnostic pop
}
bool KernelCollector::LoadParameters() {