Fixed some bugs/warnings that GCC caught

This commit is contained in:
David Anderson 2006-08-17 16:41:41 +00:00
parent 8b055fd1d0
commit db175082ad
8 changed files with 20 additions and 24 deletions

View File

@ -65,7 +65,10 @@ int HashFunction<String>(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<const char *>(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<sKeyDef> 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;

View File

@ -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<int>(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;

View File

@ -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;

View File

@ -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<char>(*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<short>(*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<int>(*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]);

View File

@ -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;

View File

@ -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
}

View File

@ -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();

View File

@ -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)