Fix compiler warnings in dbus-binding-generator
Do this for both in repository code and generated code.
Bug: 26379019
Test: compiles, unittests pass
Change-Id: Ic1e387d914696639c0ad495d3ecb6f0a60bcb981
diff --git a/Android.mk b/Android.mk
index 0597666..544d8da 100644
--- a/Android.mk
+++ b/Android.mk
@@ -14,7 +14,7 @@
LOCAL_PATH := $(call my-dir)
-libdbusBindingGenCFlags := -Wno-unused-parameter
+libdbusBindingGenCFlags := -Wall -Werror
include $(CLEAR_VARS)
LOCAL_MODULE := libdbus-binding-gen-host
diff --git a/chromeos-dbus-bindings/proxy_generator.cc b/chromeos-dbus-bindings/proxy_generator.cc
index 55c9eee..8c295ee 100644
--- a/chromeos-dbus-bindings/proxy_generator.cc
+++ b/chromeos-dbus-bindings/proxy_generator.cc
@@ -767,7 +767,7 @@
// static
void ProxyGenerator::AddMethodMock(const Interface::Method& method,
- const string& interface_name,
+ const string& /* interface_name */,
IndentedText* text) {
DbusSignature signature;
vector<string> arguments;
@@ -794,7 +794,7 @@
// static
void ProxyGenerator::AddAsyncMethodMock(const Interface::Method& method,
- const string& interface_name,
+ const string& /* interface_name */,
IndentedText* text) {
DbusSignature signature;
vector<string> arguments;
@@ -1137,6 +1137,22 @@
void ProxyGenerator::ObjectManager::AddOnPropertyChanged(
const std::vector<Interface>& interfaces,
IndentedText* text) {
+ // If there are no interfaces with properties, comment out parameter
+ // names for OnPropertyChanged() to prevent compiler warnings on unused
+ // function parameters.
+ auto has_props = [](const Interface& itf) { return !itf.properties.empty(); };
+ auto itf_with_props = std::find_if(interfaces.begin(), interfaces.end(),
+ has_props);
+ if (itf_with_props == interfaces.end()) {
+ text->AddLineAndPushOffsetTo("void OnPropertyChanged("
+ "const dbus::ObjectPath& /* object_path */,",
+ 1, '(');
+ text->AddLine("const std::string& /* interface_name */,");
+ text->AddLine("const std::string& /* property_name */) {}");
+ text->PopOffset();
+ text->AddBlankLine();
+ return;
+ }
text->AddLineAndPushOffsetTo("void OnPropertyChanged("
"const dbus::ObjectPath& object_path,",
1, '(');
diff --git a/chromeos-dbus-bindings/proxy_generator_unittest.cc b/chromeos-dbus-bindings/proxy_generator_unittest.cc
index 4eda77c..728e977 100644
--- a/chromeos-dbus-bindings/proxy_generator_unittest.cc
+++ b/chromeos-dbus-bindings/proxy_generator_unittest.cc
@@ -1196,10 +1196,9 @@
}
private:
- void OnPropertyChanged(const dbus::ObjectPath& object_path,
- const std::string& interface_name,
- const std::string& property_name) {
- }
+ void OnPropertyChanged(const dbus::ObjectPath& /* object_path */,
+ const std::string& /* interface_name */,
+ const std::string& /* property_name */) {}
void ObjectAdded(
const dbus::ObjectPath& object_path,