Remove liblog usage in MQDescriptor.h
Also remove hidl_log_base class since static methods
in child classes will not be able to invoke
logAlwaysFatal().
Bug: 36070915
Test: hidl_test passes.
Change-Id: I90e8982698920e6710f7bc8e533e4eccdf3a35c7
diff --git a/base/HidlInternal.cpp b/base/HidlInternal.cpp
index 4f88be5..36ffae8 100644
--- a/base/HidlInternal.cpp
+++ b/base/HidlInternal.cpp
@@ -32,7 +32,7 @@
namespace hardware {
namespace details {
-void hidl_log_base::logAlwaysFatal(const char *message) const {
+void logAlwaysFatal(const char *message) {
LOG(FATAL) << message;
}
diff --git a/base/include/hidl/HidlInternal.h b/base/include/hidl/HidlInternal.h
index c0250fb..6c0d8df 100644
--- a/base/include/hidl/HidlInternal.h
+++ b/base/include/hidl/HidlInternal.h
@@ -28,12 +28,9 @@
namespace hardware {
namespace details {
-// hidl_log_base is a base class that templatized
-// classes implemented in a header can inherit from,
-// to avoid creating dependencies on liblog.
-struct hidl_log_base {
- void logAlwaysFatal(const char *message) const;
-};
+//Templated classes can use the below method
+//to avoid creating dependencies on liblog.
+void logAlwaysFatal(const char *message);
// HIDL client/server code should *NOT* use this class.
//
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index f2e1265..f6ce09b 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -288,7 +288,7 @@
////////////////////////////////////////////////////////////////////////////////
template<typename T>
-struct hidl_vec : private details::hidl_log_base {
+struct hidl_vec {
hidl_vec()
: mBuffer(NULL),
mSize(0),
@@ -308,7 +308,7 @@
hidl_vec(const std::initializer_list<T> list)
: mOwnsBuffer(true) {
if (list.size() > UINT32_MAX) {
- logAlwaysFatal("hidl_vec can't hold more than 2^32 elements.");
+ details::logAlwaysFatal("hidl_vec can't hold more than 2^32 elements.");
}
mSize = static_cast<uint32_t>(list.size());
mBuffer = new T[mSize];
@@ -339,7 +339,7 @@
}
mBuffer = data;
if (size > UINT32_MAX) {
- logAlwaysFatal("external vector size exceeds 2^32 elements.");
+ details::logAlwaysFatal("external vector size exceeds 2^32 elements.");
}
mSize = static_cast<uint32_t>(size);
mOwnsBuffer = shouldOwn;
@@ -433,7 +433,7 @@
void resize(size_t size) {
if (size > UINT32_MAX) {
- logAlwaysFatal("hidl_vec can't hold more than 2^32 elements.");
+ details::logAlwaysFatal("hidl_vec can't hold more than 2^32 elements.");
}
T *newBuffer = new T[size];
diff --git a/base/include/hidl/MQDescriptor.h b/base/include/hidl/MQDescriptor.h
index 48e59dd..bf2f8a4 100644
--- a/base/include/hidl/MQDescriptor.h
+++ b/base/include/hidl/MQDescriptor.h
@@ -19,6 +19,7 @@
#include <android-base/macros.h>
#include <cutils/native_handle.h>
+#include <hidl/HidlInternal.h>
#include <hidl/HidlSupport.h>
#include <utils/Log.h>
@@ -116,7 +117,9 @@
//TODO(b/34160777) Identify a better solution that supports remoting.
static inline size_t alignToWordBoundary(size_t length) {
constexpr size_t kAlignmentSize = 64;
- LOG_ALWAYS_FATAL_IF(kAlignmentSize % __WORDSIZE != 0, "Incompatible word size");
+ if (kAlignmentSize % __WORDSIZE != 0) {
+ details::logAlwaysFatal("Incompatible word size");
+ }
return (length + kAlignmentSize/8 - 1) & ~(kAlignmentSize/8 - 1U);
}
@@ -161,8 +164,9 @@
mFlags(flavor) {
mGrantors.resize(grantors.size());
for (size_t i = 0; i < grantors.size(); ++i) {
- LOG_ALWAYS_FATAL_IF(isAlignedToWordBoundary(grantors[i].offset) == false,
- "Grantor offsets need to be aligned");
+ if (isAlignedToWordBoundary(grantors[i].offset) == false) {
+ details::logAlwaysFatal("Grantor offsets need to be aligned");
+ }
mGrantors[i] = grantors[i];
}
}