diff options
author | Haru <haru@dotalux.com> | 2015-12-26 02:28:59 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-05-08 19:53:57 +0200 |
commit | 2349b2a1528fe5dc41d930f8dd332df5ba521eb6 (patch) | |
tree | 3656a91a896f0ef090606b2b4c9184ad73153a3f /src/common/showmsg.c | |
parent | 58a7bf46508b7f186704e7efb39576e09f0ab866 (diff) | |
download | hercules-2349b2a1528fe5dc41d930f8dd332df5ba521eb6.tar.gz hercules-2349b2a1528fe5dc41d930f8dd332df5ba521eb6.tar.bz2 hercules-2349b2a1528fe5dc41d930f8dd332df5ba521eb6.tar.xz hercules-2349b2a1528fe5dc41d930f8dd332df5ba521eb6.zip |
Fixed various issues pointed out by cppcheck
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common/showmsg.c')
-rw-r--r-- | src/common/showmsg.c | 13 |
1 files changed, 5 insertions, 8 deletions
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); |