From 0f7950245a16bd8eb4a4b79cf868e25fefe51df2 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Fri, 8 Feb 2019 17:13:48 +0000 Subject: [PATCH] Actually don't error if a symbol is not required --- lib/gamemode_client.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/gamemode_client.h b/lib/gamemode_client.h index 0fe749b..d379eec 100644 --- a/lib/gamemode_client.h +++ b/lib/gamemode_client.h @@ -101,10 +101,8 @@ static api_call_pid_return_int REAL_internal_gamemode_request_end_for = NULL; * * Returns 0 on success and -1 on failure */ -__attribute__((always_inline)) static inline int internal_bind_libgamemode_symbol(void *handle, - const char *name, - void **out_func, - size_t func_size) +__attribute__((always_inline)) static inline int internal_bind_libgamemode_symbol( + void *handle, const char *name, void **out_func, size_t func_size, bool required) { void *symbol_lookup = NULL; char *dl_error = NULL; @@ -112,7 +110,7 @@ __attribute__((always_inline)) static inline int internal_bind_libgamemode_symbo /* Safely look up the symbol */ symbol_lookup = dlsym(handle, name); dl_error = dlerror(); - if (dl_error || !symbol_lookup) { + if (required && (dl_error || !symbol_lookup)) { snprintf(internal_gamemode_client_error_string, sizeof(internal_gamemode_client_error_string), "dlsym failed - %s", @@ -196,8 +194,8 @@ __attribute__((always_inline)) static inline int internal_load_libgamemode(void) if (internal_bind_libgamemode_symbol(libgamemode, binder->name, binder->functor, - binder->func_size) != 0 && - binder->required) { + binder->func_size, + binder->required)) { internal_libgamemode_loaded = -1; return -1; };