diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/grfio.c | 2 | ||||
-rw-r--r-- | src/common/memmgr.c | 6 | ||||
-rw-r--r-- | src/common/showmsg.c | 13 | ||||
-rw-r--r-- | src/common/sql.c | 2 |
4 files changed, 10 insertions, 13 deletions
diff --git a/src/common/grfio.c b/src/common/grfio.c index 678875c91..c6e47d357 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -410,12 +410,12 @@ void *grfio_reads(const char *fname, int *size) // LocalFileCheck char lfname[256]; FILE *in; - unsigned char *buf = NULL; grfio_localpath_create(lfname, sizeof(lfname), (entry && entry->fnd) ? entry->fnd : fname); in = fopen(lfname, "rb"); if (in != NULL) { int declen; + unsigned char *buf = NULL; fseek(in,0,SEEK_END); declen = (int)ftell(in); if (declen == -1) { diff --git a/src/common/memmgr.c b/src/common/memmgr.c index 15e55fbeb..dfea24465 100644 --- a/src/common/memmgr.c +++ b/src/common/memmgr.c @@ -154,8 +154,8 @@ void* aReallocz_(void *p, size_t size, const char *file, int line, const char *f #ifdef USE_MEMMGR ret = REALLOC(p, size, file, line, func); #else - size_t newSize; - if (p) { + if (p != NULL) { + size_t newSize; size_t oldSize = BUFFER_SIZE(p); ret = REALLOC(p, size, file, line, func); newSize = BUFFER_SIZE(ret); @@ -167,7 +167,7 @@ void* aReallocz_(void *p, size_t size, const char *file, int line, const char *f memset(ret, 0, BUFFER_SIZE(ret)); } #endif - if (ret == NULL){ + if (ret == NULL) { ShowFatalError("%s:%d: in func %s: aRealloc error out of memory!\n",file,line,func); exit(EXIT_FAILURE); } diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 1c1d4ca8b..8ed8efc1d 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -244,13 +244,13 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) continue; } else if (*q == ';') { // delimiter - if (numpoint < sizeof(numbers)/sizeof(*numbers)) { + if (numpoint < ARRAYLENGTH(numbers)) { // go to next array position numpoint++; } else { // array is full, so we 'forget' the first value - memmove(numbers,numbers+1,sizeof(numbers)/sizeof(*numbers)-1); - numbers[sizeof(numbers)/sizeof(*numbers)-1]=0; + memmove(numbers, numbers+1, ARRAYLENGTH(numbers)-1); + numbers[ARRAYLENGTH(numbers)-1]=0; } ++q; // and next number @@ -605,9 +605,6 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap) { va_list apcopy; char prefix[100]; -#if defined(DEBUGLOGMAP) || defined(DEBUGLOGCHAR) || defined(DEBUGLOGLOGIN) - FILE *fp; -#endif if (!string || *string == '\0') { ShowError("Empty string passed to vShowMessage_().\n"); @@ -702,8 +699,8 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap) } #if defined(DEBUGLOGMAP) || defined(DEBUGLOGCHAR) || defined(DEBUGLOGLOGIN) - if(strlen(DEBUGLOGPATH) > 0) { - fp=fopen(DEBUGLOGPATH,"a"); + if (strlen(DEBUGLOGPATH) > 0) { + FILE *fp = fopen(DEBUGLOGPATH,"a"); if (fp == NULL) { FPRINTF(STDERR, CL_RED"[ERROR]"CL_RESET": Could not open '"CL_WHITE"%s"CL_RESET"', access denied.\n", DEBUGLOGPATH); FFLUSH(STDERR); diff --git a/src/common/sql.c b/src/common/sql.c index 1eae1b29b..ef8cde536 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -880,10 +880,10 @@ void SqlStmt_Free(struct SqlStmt *self) } /* receives mysql error codes during runtime (not on first-time-connects) */ void hercules_mysql_error_handler(unsigned int ecode) { - static unsigned int retry = 1; switch( ecode ) { case 2003:/* Can't connect to MySQL (this error only happens here when failing to reconnect) */ if( mysql_reconnect_type == 1 ) { + static unsigned int retry = 1; if( ++retry > mysql_reconnect_count ) { ShowFatalError("MySQL has been unreachable for too long, %u reconnects were attempted. Shutting Down\n", retry); exit(EXIT_FAILURE); |