From 384aec522a5f6919a6fb105ff8f825d92f7fd468 Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 29 Oct 2014 17:05:15 +0000 Subject: [PATCH] Fix a couple of clang warnings. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@4697 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/baselayer.h | 4 ++-- polymer/eduke32/build/include/compat.h | 15 ++++++++++++--- polymer/eduke32/build/src/baselayer.c | 4 ++-- polymer/eduke32/build/src/build.c | 8 ++++---- polymer/eduke32/build/src/compat.c | 2 +- polymer/eduke32/build/src/lz4.c | 7 ++++--- polymer/eduke32/source/common.c | 2 +- polymer/eduke32/source/game.c | 8 ++++---- 8 files changed, 30 insertions(+), 20 deletions(-) diff --git a/polymer/eduke32/build/include/baselayer.h b/polymer/eduke32/build/include/baselayer.h index ed7e6127a..cd06cdc74 100644 --- a/polymer/eduke32/build/include/baselayer.h +++ b/polymer/eduke32/build/include/baselayer.h @@ -89,8 +89,8 @@ extern char inputdevices; #define NUMKEYS 256 #define KEYSTATUSSIZ 256 #define KEYFIFOSIZ 64 -extern char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend; -extern char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; +extern char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyasciififo[KEYFIFOSIZ]; +extern uint8_t keyasciififoplc, keyasciififoend, keyfifoplc, keyfifoend; extern char scantoasc[128], remap[KEYSTATUSSIZ], key_names[NUMKEYS][24]; extern int32_t remapinit; diff --git a/polymer/eduke32/build/include/compat.h b/polymer/eduke32/build/include/compat.h index 7d96e1185..e495e266f 100644 --- a/polymer/eduke32/build/include/compat.h +++ b/polymer/eduke32/build/include/compat.h @@ -44,10 +44,12 @@ # define __has_extension __has_feature // Compatibility with pre-3.0 compilers. #endif -#ifndef UNREFERENCED_PARAMETER - #define UNREFERENCED_PARAMETER(x) x=x +#ifdef UNREFERENCED_PARAMETER +#undef UNREFERENCED_PARAMETER #endif +#define UNREFERENCED_PARAMETER(x) x = x + #if defined __GNUC__ || defined __clang__ # define ATTRIBUTE(attrlist) __attribute__(attrlist) #else @@ -582,7 +584,15 @@ static inline uint16_t system_15bit_rand(void) { return ((uint16_t)rand())&0x7ff # define Bcalloc calloc # define Brealloc realloc # define Bfree free +#ifdef __cplusplus +# define Bstrdup _strdup +# define Bchdir _chdir +# define Bgetcwd _getcwd +#else # define Bstrdup strdup +# define Bchdir chdir +# define Bgetcwd getcwd +#endif # define Bmemalign memalign # define Bopen open # define Bclose close @@ -680,7 +690,6 @@ static inline uint16_t system_15bit_rand(void) { return ((uint16_t)rand())&0x7ff # define Bvsnprintf vsnprintf # endif # define Bvfprintf vfprintf -# define Bgetcwd getcwd # define Bgetenv getenv # define Btime() time(NULL) # define Butime utime diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index d0acfd46e..ef59bc90e 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -10,8 +10,8 @@ // input char inputdevices=0; -char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend; -char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; +char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyasciififo[KEYFIFOSIZ]; +uint8_t keyfifoplc, keyfifoend, keyasciififoplc, keyasciififoend; char remap[KEYSTATUSSIZ]; int32_t remapinit=0; char key_names[NUMKEYS][24]; diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 43d0e50d2..420e0a189 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -10695,7 +10695,7 @@ void test_map(int32_t mode) if ((program_origcwd[0] == '\0') || !getcwd(current_cwd, BMAX_PATH)) current_cwd[0] = '\0'; else // Before we check if file exists, for the case there's no absolute path. - chdir(program_origcwd); + Bchdir(program_origcwd); fp = fopen(game_executable, "rb"); // File exists? if (fp != NULL) @@ -10719,7 +10719,7 @@ void test_map(int32_t mode) } if (current_cwd[0] != '\0') // Temporarily changing back, - chdir(current_cwd); // after checking if file exists. + Bchdir(current_cwd); // after checking if file exists. if (testplay_addparam) slen = Bstrlen(testplay_addparam); @@ -10765,10 +10765,10 @@ void test_map(int32_t mode) #else if (current_cwd[0] != '\0') { - chdir(program_origcwd); + Bchdir(program_origcwd); if (system(fullparam)) message("Error launching the game!"); - chdir(current_cwd); + Bchdir(current_cwd); } else system(fullparam); #endif diff --git a/polymer/eduke32/build/src/compat.c b/polymer/eduke32/build/src/compat.c index 357be91a7..d791114dd 100644 --- a/polymer/eduke32/build/src/compat.c +++ b/polymer/eduke32/build/src/compat.c @@ -97,7 +97,7 @@ void *Bmalloc(bsize_t size) void Bfree(void *ptr) { - free(ptr); + Bfree(ptr); } int32_t Bopen(const char *pathname, int32_t flags, uint32_t mode) diff --git a/polymer/eduke32/build/src/lz4.c b/polymer/eduke32/build/src/lz4.c index ee37895f4..0f01a098d 100644 --- a/polymer/eduke32/build/src/lz4.c +++ b/polymer/eduke32/build/src/lz4.c @@ -157,11 +157,12 @@ /************************************** Memory routines **************************************/ +#include "compat.h" #include /* malloc, calloc, free */ -#define ALLOCATOR(n,s) calloc(n,s) -#define FREEMEM free +#define ALLOCATOR(n,s) Xcalloc(n,s) +#define FREEMEM Bfree #include /* memset, memcpy */ -#define MEM_INIT memset +#define MEM_INIT Bmemset /************************************** diff --git a/polymer/eduke32/source/common.c b/polymer/eduke32/source/common.c index c9e066227..2a7c0bae4 100644 --- a/polymer/eduke32/source/common.c +++ b/polymer/eduke32/source/common.c @@ -352,7 +352,7 @@ void G_ExtInit(void) else asperr = -1; } if (asperr == 0) - chdir(cwd); + Bchdir(cwd); Bfree(homedir); } } diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index ebbb96b47..ff23ebeb2 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -11021,15 +11021,15 @@ static void G_Startup(void) if (g_modDir[0] != '/' && (cwd = getcwd(NULL, 0))) { - chdir(g_modDir); + Bchdir(g_modDir); if (loadpics("tiles000.art",MAXCACHE1DSIZE) < 0) { - chdir(cwd); + Bchdir(cwd); if (loadpics("tiles000.art",MAXCACHE1DSIZE) < 0) G_GameExit("Failed loading art."); } - chdir(cwd); - free(cwd); + Bchdir(cwd); + Bfree(cwd); } else if (loadpics("tiles000.art",MAXCACHE1DSIZE) < 0) G_GameExit("Failed loading art.");