2653fe
From bcbb8ea8e6ced976d4359db9bc4c35a9d8f345ba Mon Sep 17 00:00:00 2001
2653fe
From: lambdadroid <lambdadroid@gmail.com>
2653fe
Date: Tue, 6 Jun 2017 15:56:37 +0200
2653fe
Subject: [PATCH] Android: Fix compile errors
2653fe
2653fe
Android doesn't have DBUS so all functionality related to it
2653fe
must be disabled by checking if GLIB_SUPPORT is defined.
2653fe
2653fe
Currently, the build also fails with the following error:
2653fe
thd_trip_point.h:139:2: error: control may reach end of non-void function
2653fe
2653fe
This is because the exception is excluded for Android, and nothing is
2653fe
returned if an invalid index is given into the method.
2653fe
2653fe
The easiest way to fix this is to exclude the method entirely for
2653fe
Android. The method is only used from DBUS code so it doesn't
2653fe
cause any problems if Android doesn't have it.
2653fe
---
2653fe
 src/thd_engine_default.cpp | 9 +++++++--
2653fe
 src/thd_trip_point.h       | 4 ++--
2653fe
 2 files changed, 9 insertions(+), 4 deletions(-)
2653fe
2653fe
diff --git a/src/thd_engine_default.cpp b/src/thd_engine_default.cpp
2653fe
index ef0b588..0d4c55c 100644
2653fe
--- a/src/thd_engine_default.cpp
2653fe
+++ b/src/thd_engine_default.cpp
2653fe
@@ -36,7 +36,10 @@
2653fe
 #include "thd_cdev_rapl_dram.h"
2653fe
 #include "thd_sensor_virtual.h"
2653fe
 #include "thd_cdev_backlight.h"
2653fe
+
2653fe
+#ifdef GLIB_SUPPORT
2653fe
 #include "thd_cdev_modem.h"
2653fe
+#endif
2653fe
 
2653fe
 // Default CPU cooling devices, which are not part of thermal sysfs
2653fe
 // Since non trivial initialization is not supported, we init all fields even if they are not needed
2653fe
@@ -502,7 +505,8 @@ int cthd_engine_default::add_replace_cdev(cooling_dev_t *config) {
2653fe
 	}
2653fe
 	if (!cdev_present) {
2653fe
 		// create new
2653fe
-		if (config->type_string.compare("intel_modem") == 0)
2653fe
+		if (config->type_string.compare("intel_modem") == 0) {
2653fe
+#ifdef GLIB_SUPPORT
2653fe
 			/*
2653fe
 			 * Add Modem as cdev
2653fe
 			 * intel_modem is a modem identifier across all intel platforms.
2653fe
@@ -510,7 +514,8 @@ int cthd_engine_default::add_replace_cdev(cooling_dev_t *config) {
2653fe
 			 * are to be taken care in the cdev implementation.
2653fe
 			 */
2653fe
 			cdev = new cthd_cdev_modem(current_cdev_index, config->path_str);
2653fe
-		else
2653fe
+#endif
2653fe
+		} else
2653fe
 			cdev = new cthd_gen_sysfs_cdev(current_cdev_index, config->path_str);
2653fe
 		if (!cdev)
2653fe
 			return THD_ERROR;
2653fe
diff --git a/src/thd_trip_point.h b/src/thd_trip_point.h
2653fe
index 746f82f..7981d58 100644
2653fe
--- a/src/thd_trip_point.h
2653fe
+++ b/src/thd_trip_point.h
2653fe
@@ -129,14 +129,14 @@ class cthd_trip_point {
2653fe
 		return cdevs.size();
2653fe
 	}
2653fe
 
2653fe
+#ifndef ANDROID
2653fe
 	trip_pt_cdev_t &get_cdev_at_index(unsigned int index) {
2653fe
 		if (index < cdevs.size())
2653fe
 			return cdevs[index];
2653fe
-#ifndef ANDROID
2653fe
 		else
2653fe
 			throw std::invalid_argument("index");
2653fe
-#endif
2653fe
 	}
2653fe
+#endif
2653fe
 
2653fe
 	void trip_cdev_add(trip_pt_cdev_t trip_cdev) {
2653fe
 		int index;