summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Wiley <wiley@google.com>2016-01-04 09:59:49 -0800
committerChristopher Wiley <wiley@google.com>2016-01-04 11:19:00 -0800
commit4d7450f26396d6a5d3135e058873d484c3857aa0 (patch)
tree84efcf8cbb9e56db9f9bbccc4491e0a5689bd3f1
parent9f6fb89c67950128c98e723fad5263369f103faf (diff)
downloaddbus-binding-generator-brillo-m9-dev.tar.gz
Fix compiler warnings in dbus-binding-generatorbrillo-m9-releasebrillo-m9-dev
Do this for both in repository code and generated code. Bug: 26379019 Test: compiles, unittests pass Change-Id: Ic1e387d914696639c0ad495d3ecb6f0a60bcb981
-rw-r--r--Android.mk2
-rw-r--r--chromeos-dbus-bindings/proxy_generator.cc20
-rw-r--r--chromeos-dbus-bindings/proxy_generator_unittest.cc7
3 files changed, 22 insertions, 7 deletions
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 @@ void ProxyGenerator::AddAsyncMethodProxy(const Interface::Method& method,
// 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 @@ void ProxyGenerator::AddMethodMock(const Interface::Method& method,
// 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::AddInterfaceAccessors(
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 @@ class ObjectManagerProxy : public dbus::ObjectManager::Interface {
}
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,