From 3c920996b80ddbce6a431b862ee6fda2cef71ee5 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 5 Nov 2019 10:43:09 +0100 Subject: [PATCH 1/3] Make memcmp usage clearer Signed-off-by: Gabriel Ravier --- src/Map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Map.cpp b/src/Map.cpp index 06ce24b0..dde99212 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -41,7 +41,7 @@ BOOL LoadMapData2(const char *path_map) char check[3]; fread(check, 1, 3, fp); - if (memcmp(check, code_pxma, 3)) + if (memcmp(check, code_pxma, 3) != 0) { fclose(fp); return FALSE; From 053770b81b4b09c0219b6da53c358d6280534c82 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 4 Nov 2019 09:50:23 +0100 Subject: [PATCH 2/3] Use "strcmp(a, b) != 0" so it's clearer what we're checking for Signed-off-by: Gabriel Ravier --- src/Config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config.cpp b/src/Config.cpp index 9c30d537..30b14d34 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -31,7 +31,7 @@ BOOL LoadConfigData(CONFIG *conf) fclose(fp); // Check if version is not correct, and return if it failed - if (fread_result != 1 || strcmp(conf->proof, config_magic)) + if (fread_result != 1 || strcmp(conf->proof, config_magic) != 0) { memset(conf, 0, sizeof(CONFIG)); return FALSE; From f96b7fa56607e73e80019c031a7095b9d02f9463 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 5 Nov 2019 17:16:20 +0100 Subject: [PATCH 3/3] Use "memcmp(a, b) != 0" instead of "memcmp(a, b)" so it's clearer we're searching for a difference Signed-off-by: Gabriel Ravier --- src/NpChar.cpp | 2 +- src/Profile.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NpChar.cpp b/src/NpChar.cpp index 9e50f2b3..589eab8b 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -68,7 +68,7 @@ BOOL LoadEvent(const char *path_event) // Read "PXE" check char code[4]; fread(code, 1, 4, fp); - if (memcmp(code, gPassPixEve, 3)) + if (memcmp(code, gPassPixEve, 3) != 0) { #ifdef FIX_BUGS // The original game forgot to close the file here diff --git a/src/Profile.cpp b/src/Profile.cpp index 0f0cb37f..f9dc051c 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -104,7 +104,7 @@ BOOL LoadProfile(const char *name) // Check header code fread(profile.code, 8, 1, fp); - if (memcmp(profile.code, gProfileCode, 8)) + if (memcmp(profile.code, gProfileCode, 8) != 0) { #ifdef FIX_BUGS fclose(fp); // The original game forgets to close the file