Blob Blame History Raw
From bcbb8ea8e6ced976d4359db9bc4c35a9d8f345ba Mon Sep 17 00:00:00 2001
From: lambdadroid <lambdadroid@gmail.com>
Date: Tue, 6 Jun 2017 15:56:37 +0200
Subject: [PATCH] Android: Fix compile errors

Android doesn't have DBUS so all functionality related to it
must be disabled by checking if GLIB_SUPPORT is defined.

Currently, the build also fails with the following error:
thd_trip_point.h:139:2: error: control may reach end of non-void function

This is because the exception is excluded for Android, and nothing is
returned if an invalid index is given into the method.

The easiest way to fix this is to exclude the method entirely for
Android. The method is only used from DBUS code so it doesn't
cause any problems if Android doesn't have it.
---
 src/thd_engine_default.cpp | 9 +++++++--
 src/thd_trip_point.h       | 4 ++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/thd_engine_default.cpp b/src/thd_engine_default.cpp
index ef0b588..0d4c55c 100644
--- a/src/thd_engine_default.cpp
+++ b/src/thd_engine_default.cpp
@@ -36,7 +36,10 @@
 #include "thd_cdev_rapl_dram.h"
 #include "thd_sensor_virtual.h"
 #include "thd_cdev_backlight.h"
+
+#ifdef GLIB_SUPPORT
 #include "thd_cdev_modem.h"
+#endif
 
 // Default CPU cooling devices, which are not part of thermal sysfs
 // Since non trivial initialization is not supported, we init all fields even if they are not needed
@@ -502,7 +505,8 @@ int cthd_engine_default::add_replace_cdev(cooling_dev_t *config) {
 	}
 	if (!cdev_present) {
 		// create new
-		if (config->type_string.compare("intel_modem") == 0)
+		if (config->type_string.compare("intel_modem") == 0) {
+#ifdef GLIB_SUPPORT
 			/*
 			 * Add Modem as cdev
 			 * intel_modem is a modem identifier across all intel platforms.
@@ -510,7 +514,8 @@ int cthd_engine_default::add_replace_cdev(cooling_dev_t *config) {
 			 * are to be taken care in the cdev implementation.
 			 */
 			cdev = new cthd_cdev_modem(current_cdev_index, config->path_str);
-		else
+#endif
+		} else
 			cdev = new cthd_gen_sysfs_cdev(current_cdev_index, config->path_str);
 		if (!cdev)
 			return THD_ERROR;
diff --git a/src/thd_trip_point.h b/src/thd_trip_point.h
index 746f82f..7981d58 100644
--- a/src/thd_trip_point.h
+++ b/src/thd_trip_point.h
@@ -129,14 +129,14 @@ class cthd_trip_point {
 		return cdevs.size();
 	}
 
+#ifndef ANDROID
 	trip_pt_cdev_t &get_cdev_at_index(unsigned int index) {
 		if (index < cdevs.size())
 			return cdevs[index];
-#ifndef ANDROID
 		else
 			throw std::invalid_argument("index");
-#endif
 	}
+#endif
 
 	void trip_cdev_add(trip_pt_cdev_t trip_cdev) {
 		int index;