From b9b150e638c9b6d468b4181547c42dc53092cdbf Mon Sep 17 00:00:00 2001 From: Headline Date: Sun, 29 Jul 2018 04:09:18 -0700 Subject: [PATCH 1/3] Fix warnings for SM builds --- core/sourcehook/sh_memory.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/core/sourcehook/sh_memory.h b/core/sourcehook/sh_memory.h index 7f16fba..3aed943 100644 --- a/core/sourcehook/sh_memory.h +++ b/core/sourcehook/sh_memory.h @@ -255,7 +255,7 @@ namespace SourceHook */ namespace { - bool ModuleInMemory(char *addr, size_t len) + inline bool ModuleInMemory(char *addr, size_t len) { #if SH_SYS == SH_SYS_LINUX // On linux, first check /proc/self/maps @@ -328,12 +328,6 @@ namespace SourceHook prevHandler = signal(SIGSEGV, BadReadHandler); - volatile const char *p = reinterpret_cast(addr); - char dummy; - - for (size_t i = 0; i < len; i++) - dummy = p[i]; - g_BadReadCalled = false; signal(SIGSEGV, prevHandler); From 37738022eeb8ffaa7cf3baf67bfd968e01db3bbd Mon Sep 17 00:00:00 2001 From: Michael Flaherty Date: Tue, 31 Jul 2018 13:17:48 -0700 Subject: [PATCH 2/3] dvander foxes --- core/sourcehook/sh_memory.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/sourcehook/sh_memory.h b/core/sourcehook/sh_memory.h index 3aed943..c2130d6 100644 --- a/core/sourcehook/sh_memory.h +++ b/core/sourcehook/sh_memory.h @@ -255,7 +255,7 @@ namespace SourceHook */ namespace { - inline bool ModuleInMemory(char *addr, size_t len) + static inline bool ModuleInMemory(char *addr, size_t len) { #if SH_SYS == SH_SYS_LINUX // On linux, first check /proc/self/maps @@ -328,6 +328,10 @@ namespace SourceHook prevHandler = signal(SIGSEGV, BadReadHandler); + volatile const char *p = reinterpret_cast(addr); + for (size_t i = 0; i < len; i++) + p[i]; + g_BadReadCalled = false; signal(SIGSEGV, prevHandler); @@ -349,10 +353,8 @@ namespace SourceHook return false; volatile const char *p = reinterpret_cast(addr); - char dummy; - for (size_t i = 0; i < len; i++) - dummy = p[i]; + p[i]; g_BadReadCalled = false; From d5030d06123b56fb96ab447fab8a508fc7ccab49 Mon Sep 17 00:00:00 2001 From: Headline Date: Tue, 31 Jul 2018 21:14:08 -0700 Subject: [PATCH 3/3] Re-add dummy, cast to void --- core/sourcehook/sh_memory.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/sourcehook/sh_memory.h b/core/sourcehook/sh_memory.h index c2130d6..bd36e79 100644 --- a/core/sourcehook/sh_memory.h +++ b/core/sourcehook/sh_memory.h @@ -329,8 +329,11 @@ namespace SourceHook prevHandler = signal(SIGSEGV, BadReadHandler); volatile const char *p = reinterpret_cast(addr); + char dummy; + for (size_t i = 0; i < len; i++) - p[i]; + dummy = p[i]; + (void)dummy; // silence unused var, we must read from p g_BadReadCalled = false; @@ -353,8 +356,11 @@ namespace SourceHook return false; volatile const char *p = reinterpret_cast(addr); + char dummy; + for (size_t i = 0; i < len; i++) - p[i]; + dummy = p[i]; + (void)dummy; // silence unused var, we must read from p g_BadReadCalled = false;