LegacySupport: fix compile error for some devices
Some build configurations were failing to implicitly static cast and use
the sp<> comparison operator here, resulting in this error:
system/libhidl/transport/include/hidl/LegacySupport.h:45:53: error: invalid operands to binary expression ('::android::hardware::Return< ::android::sp< ::android::hardware::audio::V5_0::IDevicesFactory> >' and 'nullptr_t')
LOG_FATAL_IF(ExpectInterface::castFrom(service) == nullptr,
Bug: N/A
Test: builds now
Change-Id: Ie2e494a33f0ff576359361a46aea080a05ee0181
diff --git a/transport/include/hidl/LegacySupport.h b/transport/include/hidl/LegacySupport.h
index 0f37ae0..7cb72a9 100644
--- a/transport/include/hidl/LegacySupport.h
+++ b/transport/include/hidl/LegacySupport.h
@@ -42,9 +42,10 @@
LOG_FATAL_IF(service->isRemote(), "Implementation of %s/%s is remote!",
Interface::descriptor, name.c_str());
- LOG_FATAL_IF(ExpectInterface::castFrom(service) == nullptr,
- "Implementation of %s/%s is not a %s!", Interface::descriptor, name.c_str(),
- ExpectInterface::descriptor);
+
+ sp<ExpectInterface> expected = ExpectInterface::castFrom(service);
+ LOG_FATAL_IF(expected == nullptr, "Implementation of %s/%s is not a %s!", Interface::descriptor,
+ name.c_str(), ExpectInterface::descriptor);
status_t status = registerServiceCb(service, name);