Fix annoying build warning
This commit is contained in:
@@ -64,12 +64,23 @@ public:
|
|||||||
|
|
||||||
class SenseApiLib
|
class SenseApiLib
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
friend class SenseApiManager;
|
||||||
|
struct DlCloser
|
||||||
|
{
|
||||||
|
void operator()(void* handle) const
|
||||||
|
{
|
||||||
|
if (handle) {
|
||||||
|
dlclose(handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SenseApiLib(
|
SenseApiLib(
|
||||||
const std::string& path, void *_dlopen_handle, getSenseApiDescFn *descFn)
|
const std::string& path, void *_dlopen_handle, getSenseApiDescFn *descFn)
|
||||||
: libraryPath(path),
|
: libraryPath(path),
|
||||||
dlopen_handle(
|
dlopen_handle(_dlopen_handle, DlCloser()),
|
||||||
_dlopen_handle, reinterpret_cast<void(*)(void*)>(&dlclose)),
|
|
||||||
HK_GET_SENSE_API_DESC_FN_NAME(descFn)
|
HK_GET_SENSE_API_DESC_FN_NAME(descFn)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -98,7 +109,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
std::string libraryPath;
|
std::string libraryPath;
|
||||||
std::unique_ptr<void, void(*)(void*)> dlopen_handle;
|
std::unique_ptr<void, DlCloser> dlopen_handle;
|
||||||
/* UNIMPLEMENTED: API-specific cmdline options. These affect this specific
|
/* UNIMPLEMENTED: API-specific cmdline options. These affect this specific
|
||||||
* sense api lib's behaviour globally.
|
* sense api lib's behaviour globally.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
namespace hk {
|
namespace hk {
|
||||||
namespace sense_api {
|
namespace sense_api {
|
||||||
|
|
||||||
class SenseApiManager {
|
class SenseApiManager
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
static SenseApiManager& getInstance()
|
static SenseApiManager& getInstance()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,14 +12,6 @@ namespace fs = std::filesystem;
|
|||||||
namespace hk {
|
namespace hk {
|
||||||
namespace sense_api {
|
namespace sense_api {
|
||||||
|
|
||||||
struct DlCloser {
|
|
||||||
void operator()(void* handle) const {
|
|
||||||
if (handle) {
|
|
||||||
dlclose(handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::optional<std::string> findLibraryPath(
|
static std::optional<std::string> findLibraryPath(
|
||||||
const std::string& libraryPath)
|
const std::string& libraryPath)
|
||||||
{
|
{
|
||||||
@@ -64,7 +56,7 @@ SenseApiLib& SenseApiManager::loadSenseApiLib(const std::string& libraryPath)
|
|||||||
|
|
||||||
// Clear any existing error
|
// Clear any existing error
|
||||||
dlerror();
|
dlerror();
|
||||||
auto dlopen_handle = std::unique_ptr<void, DlCloser>(
|
auto dlopen_handle = std::unique_ptr<void, SenseApiLib::DlCloser>(
|
||||||
dlopen(resolvedPath.c_str(), RTLD_LAZY));
|
dlopen(resolvedPath.c_str(), RTLD_LAZY));
|
||||||
if (!dlopen_handle && fullPath.has_value())
|
if (!dlopen_handle && fullPath.has_value())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user