Skip to content

Commit

Permalink
Merge pull request #2363 from kbenzie/benie/windows-improve-adapter-l…
Browse files Browse the repository at this point in the history
…oad-logging

Improve logging of loading adapters on Windows
  • Loading branch information
kbenzie authored Nov 22, 2024
2 parents 2f479e0 + da5befe commit e9d94b1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions source/common/windows/ur_lib_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void LibLoader::freeAdapterLibrary(HMODULE handle) {
BOOL res = FreeLibrary(handle);
if (!res) {
logger::error(
"Failed to unload the library with the handle at address {}",
"Failed to unload the library with the handle at address 0x{}",
handle);
} else {
logger::info("unloaded adapter 0x{}", handle);
Expand All @@ -27,10 +27,14 @@ void LibLoader::freeAdapterLibrary(HMODULE handle) {

std::unique_ptr<HMODULE, LibLoader::lib_dtor>
LibLoader::loadAdapterLibrary(const char *name) {
auto handle = std::unique_ptr<HMODULE, LibLoader::lib_dtor>(
LoadLibraryExA(name, nullptr, 0));
logger::info("loaded adapter 0x{} ({})", handle, name);
return handle;
if (HMODULE handle = LoadLibraryExA(name, nullptr, 0)) {
logger::info("loaded adapter 0x{}: {}", handle, name);
return std::unique_ptr<HMODULE, LibLoader::lib_dtor>{handle};
} else {
logger::debug("loading adapter failed with error {}: {}",
GetLastError(), name);
}
return nullptr;
}

void *LibLoader::getFunctionPtr(HMODULE handle, const char *func_name) {
Expand Down

0 comments on commit e9d94b1

Please sign in to comment.