From db175082ad499d468f57786663d049c050a71344 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 17 Aug 2006 16:41:41 +0000 Subject: [PATCH] Fixed some bugs/warnings that GCC caught --- amxmodx/CLang.cpp | 14 ++++++++++---- amxmodx/amxmodx.cpp | 9 +++------ amxmodx/debugger.h | 2 +- amxmodx/file.cpp | 9 +++------ amxmodx/libraries.cpp | 4 ++-- amxmodx/modules.cpp | 2 +- amxmodx/srvcmd.cpp | 1 - amxmodx/string.cpp | 3 --- 8 files changed, 20 insertions(+), 24 deletions(-) diff --git a/amxmodx/CLang.cpp b/amxmodx/CLang.cpp index 346a0812..ee041185 100755 --- a/amxmodx/CLang.cpp +++ b/amxmodx/CLang.cpp @@ -65,7 +65,10 @@ int HashFunction(const String &k) unsigned long hash = 5381; register const char *str = k.c_str(); register char c; - while (c = *str++) hash = ((hash << 5) + hash) + c; // hash*33 + c + while ((c = *str++)) + { + hash = ((hash << 5) + hash) + c; // hash*33 + c + } return hash; } @@ -75,7 +78,10 @@ int HashAlt(char const * const &k) unsigned long hash = 5381; register const char *str = k; register char c; - while (c = *str++) hash = ((hash << 5) + hash) + c; // hash*33 + c + while ((c = *str++)) + { + hash = ((hash << 5) + hash) + c; // hash*33 + c + } return hash; } @@ -353,7 +359,7 @@ int CLangMngr::MergeDefinitionFile(const char *file) CQueue Defq; String buf; char language[3]; - sKeyDef tmpEntry; + sKeyDef tmpEntry = {NULL, 0}; while (!feof(fp)) { @@ -570,7 +576,7 @@ bool CLangMngr::LangExists(const char *langName) char buf[3] = {0}; int i = 0; - while (buf[i] = tolower(*langName++)) + while ((buf[i] = tolower(*langName++))) { if (++i == 2) break; diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index e7b73002..f2a23ed3 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -3258,8 +3258,6 @@ static cell AMX_NATIVE_CALL callfunc_end(AMX *amx, cell *params) // native callfunc_push_float(Float: value); static cell AMX_NATIVE_CALL callfunc_push_byval(AMX *amx, cell *params) { - CPluginMngr::CPlugin *curPlugin = g_plugins.findPluginFast(amx); - if (!g_CallFunc_Plugin) { // scripter's fault @@ -3339,8 +3337,6 @@ static cell AMX_NATIVE_CALL callfunc_push_byref(AMX *amx, cell *params) // native callfunc_push_str(value[]); static cell AMX_NATIVE_CALL callfunc_push_str(AMX *amx, cell *params) { - CPluginMngr::CPlugin *curPlugin = g_plugins.findPluginFast(amx); - if (!g_CallFunc_Plugin) { // scripter's fault @@ -3500,7 +3496,9 @@ static cell AMX_NATIVE_CALL int3(AMX *amx, cell *params) /*********************************************************************/ +#if defined AMD64 static bool g_warned_ccqv = false; +#endif // native query_client_cvar(id, const cvar[], const resultfunc[]) static cell AMX_NATIVE_CALL query_client_cvar(AMX *amx, cell *params) { @@ -3735,7 +3733,6 @@ static cell AMX_NATIVE_CALL PrepareArray(AMX *amx, cell *params) static cell AMX_NATIVE_CALL ExecuteForward(AMX *amx, cell *params) { int id = static_cast(params[1]); - int str_id = 0; int len, err; cell *addr = get_amxaddr(amx, params[2]); @@ -3829,7 +3826,7 @@ void CheckAndClearPlayerHUD(CPlayer *player, int &channel, unsigned int sync_obj //get the last channel this message class was displayed on. cell last_channel = plist[player->index]; //check if the last sync on this channel was this sync obj - if (player->hudmap[last_channel] == sync_obj + 1) + if ((unsigned int)player->hudmap[last_channel] == sync_obj + 1) { //if so, we can safely REUSE it channel = (int)last_channel; diff --git a/amxmodx/debugger.h b/amxmodx/debugger.h index b7da045e..c50016fd 100755 --- a/amxmodx/debugger.h +++ b/amxmodx/debugger.h @@ -50,7 +50,7 @@ public: struct trace_info { - trace_info() : cip(0), frm(0), used(false), next(NULL), prev(NULL) {}; + trace_info() : cip(0), frm(0), next(NULL), prev(NULL), used(false) {}; cell cip; cell frm; diff --git a/amxmodx/file.cpp b/amxmodx/file.cpp index 3204acd3..500c52ff 100755 --- a/amxmodx/file.cpp +++ b/amxmodx/file.cpp @@ -358,7 +358,7 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */ static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params) { - int len, j = -1; + int len; char *file = build_pathname("%s", get_amxstring(amx, params[1], 1, len)); char *flags = get_amxstring(amx, params[2], 0, len); @@ -383,7 +383,6 @@ static cell AMX_NATIVE_CALL amx_fwrite_blocks(AMX *amx, cell *params) case 1: { char *a = new char[blocks]; - char *ptr = a; while (btmp--) *a++ = static_cast(*addr++); size_t res = fwrite(a, sizeof(char), blocks, fp); @@ -393,7 +392,6 @@ static cell AMX_NATIVE_CALL amx_fwrite_blocks(AMX *amx, cell *params) case 2: { short *a = new short[blocks]; - short *ptr = a; while (btmp--) *a++ = static_cast(*addr++); size_t res = fwrite(a, sizeof(short), blocks, fp); @@ -403,7 +401,6 @@ static cell AMX_NATIVE_CALL amx_fwrite_blocks(AMX *amx, cell *params) case 4: { int *a = new int[blocks]; - int *ptr = a; while (btmp--) *a++ = static_cast(*addr++); size_t res = fwrite(a, sizeof(int), blocks, fp); @@ -682,13 +679,13 @@ static cell AMX_NATIVE_CALL amx_open_dir(AMX *amx, cell *params) DIR *dp = opendir(dirname); if (!dp) - return NULL; + return 0; struct dirent *ep = readdir(dp); if (!ep) { closedir(dp); - return NULL; + return 0; } set_amxstring(amx, params[2], ep->d_name, params[3]); diff --git a/amxmodx/libraries.cpp b/amxmodx/libraries.cpp index 9040846d..522de44a 100644 --- a/amxmodx/libraries.cpp +++ b/amxmodx/libraries.cpp @@ -184,7 +184,7 @@ LibError RunLibCommand(const LibDecoder *enc) if ( (enc->cmd == LibCmd_ReqLib) || (enc->cmd == LibCmd_ReqClass) ) { - LibType expect; + LibType expect = LibType_Library; if (enc->cmd == LibCmd_ReqLib) expect = LibType_Library; @@ -202,7 +202,7 @@ LibError RunLibCommand(const LibDecoder *enc) } if (expect == LibType_Library) return LibErr_NoLibrary; - else if (expect = LibType_Class) + else if (expect == LibType_Class) return LibErr_NoClass; return LibErr_NoLibrary; diff --git a/amxmodx/modules.cpp b/amxmodx/modules.cpp index 13f7cd31..0ae28906 100755 --- a/amxmodx/modules.cpp +++ b/amxmodx/modules.cpp @@ -313,7 +313,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64 //set this again because amx_Init() erases it! amx->flags |= AMX_FLAG_JITC; amx->flags &= (~AMX_FLAG_DEBUG); - amx->sysreq_d = NULL; + amx->sysreq_d = 0; #endif } diff --git a/amxmodx/srvcmd.cpp b/amxmodx/srvcmd.cpp index 3c3f06c9..b70572e0 100755 --- a/amxmodx/srvcmd.cpp +++ b/amxmodx/srvcmd.cpp @@ -253,7 +253,6 @@ void amx_command() void plugin_srvcmd() { - cell ret = 0; const char* cmd = CMD_ARGV(0); CmdMngr::iterator a = g_commands.srvcmdbegin(); diff --git a/amxmodx/string.cpp b/amxmodx/string.cpp index ed2a902a..68ed9035 100755 --- a/amxmodx/string.cpp +++ b/amxmodx/string.cpp @@ -863,7 +863,6 @@ static cell AMX_NATIVE_CALL is_alpha(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_ucfirst(AMX *amx, cell *params) { - int len = 0; cell *str = get_amxaddr(amx, params[1]); if (!isalpha((char)str[0]) || !(str[0] & (1<<5))) @@ -944,7 +943,6 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params) int sublen; char *sub = get_amxstring(amx, params[2], 1, sublen); - bool found = false; bool igcase = params[3] ? true : false; if (igcase) @@ -964,7 +962,6 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params) if (params[4] > len) return -1; - char *pos = &(str[params[4]]); char *find = strstr(str, sub); if (!find)