From 8dd7aec896efc0220d6234bcfb190767c30dbb29 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 24 Jun 2018 00:13:59 +0200 Subject: Change functions to static where possible (Part 1 - common) This fixes issues with plugins defining symbols with the same names Signed-off-by: Haru --- src/common/showmsg.c | 72 +++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 34 deletions(-) (limited to 'src/common/showmsg.c') diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 8bcd1b4c7..91f84e9d3 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -45,7 +45,7 @@ #define DEBUGLOGPATH "log"PATHSEP_STR"login-server.log" #endif -struct showmsg_interface showmsg_s; +static struct showmsg_interface showmsg_s; struct showmsg_interface *showmsg; /////////////////////////////////////////////////////////////////////////////// @@ -186,7 +186,7 @@ Escape sequences for Select Character Set #define is_console(handle) (FILE_TYPE_CHAR==GetFileType(handle)) /////////////////////////////////////////////////////////////////////////////// -int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) +static int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) { ///////////////////////////////////////////////////////////////// /* XXX Two streams are being used. Disabled to avoid inconsistency [flaviojs] @@ -467,8 +467,9 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) return 0; } -int FPRINTF(HANDLE handle, const char *fmt, ...) __attribute__((format(printf, 2, 3))); -int FPRINTF(HANDLE handle, const char *fmt, ...) { +static int FPRINTF(HANDLE handle, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +static int FPRINTF(HANDLE handle, const char *fmt, ...) +{ int ret; va_list argptr; va_start(argptr, fmt); @@ -488,7 +489,7 @@ int FPRINTF(HANDLE handle, const char *fmt, ...) { #define is_console(file) (0!=isatty(fileno(file))) //vprintf_without_ansiformats -int VFPRINTF(FILE *file, const char *fmt, va_list argptr) +static int VFPRINTF(FILE *file, const char *fmt, va_list argptr) { char *p, *q; NEWBUF(tempbuf); // temporary buffer @@ -584,8 +585,9 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr) FREEBUF(tempbuf); return 0; } -int FPRINTF(FILE *file, const char *fmt, ...) __attribute__((format(printf, 2, 3))); -int FPRINTF(FILE *file, const char *fmt, ...) { +static int FPRINTF(FILE *file, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +static int FPRINTF(FILE *file, const char *fmt, ...) +{ int ret; va_list argptr; va_start(argptr, fmt); @@ -601,7 +603,7 @@ int FPRINTF(FILE *file, const char *fmt, ...) { #endif// not _WIN32 -int vShowMessage_(enum msg_type flag, const char *string, va_list ap) +static int vShowMessage_(enum msg_type flag, const char *string, va_list ap) { va_list apcopy; char prefix[100]; @@ -720,7 +722,7 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap) return 0; } -int showmsg_vShowMessage(const char *string, va_list ap) +static int showmsg_vShowMessage(const char *string, va_list ap) { int ret; va_list apcopy; @@ -730,14 +732,16 @@ int showmsg_vShowMessage(const char *string, va_list ap) return ret; } -void showmsg_clearScreen(void) +static void showmsg_clearScreen(void) { #ifndef _WIN32 ShowMessage(CL_CLS); // to prevent empty string passed messages #endif } -int ShowMessage_(enum msg_type flag, const char *string, ...) __attribute__((format(printf, 2, 3))); -int ShowMessage_(enum msg_type flag, const char *string, ...) { + +static int ShowMessage_(enum msg_type flag, const char *string, ...) __attribute__((format(printf, 2, 3))); +static int ShowMessage_(enum msg_type flag, const char *string, ...) +{ int ret; va_list ap; va_start(ap, string); @@ -747,56 +751,56 @@ int ShowMessage_(enum msg_type flag, const char *string, ...) { } // direct printf replacement -void showmsg_showMessage(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showMessage(const char *string, ...) +static void showmsg_showMessage(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showMessage(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_NONE, string, ap); va_end(ap); } -void showmsg_showStatus(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showStatus(const char *string, ...) +static void showmsg_showStatus(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showStatus(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_STATUS, string, ap); va_end(ap); } -void showmsg_showSQL(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showSQL(const char *string, ...) +static void showmsg_showSQL(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showSQL(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_SQL, string, ap); va_end(ap); } -void showmsg_showInfo(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showInfo(const char *string, ...) +static void showmsg_showInfo(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showInfo(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_INFORMATION, string, ap); va_end(ap); } -void showmsg_showNotice(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showNotice(const char *string, ...) +static void showmsg_showNotice(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showNotice(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_NOTICE, string, ap); va_end(ap); } -void showmsg_showWarning(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showWarning(const char *string, ...) +static void showmsg_showWarning(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showWarning(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_WARNING, string, ap); va_end(ap); } -void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3))); -void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...) +static void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3))); +static void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...) { StringBuf buf; va_list ap; @@ -812,24 +816,24 @@ void showmsg_showConfigWarning(struct config_setting_t *config, const char *stri va_end(ap); StrBuf->Destroy(&buf); } -void showmsg_showDebug(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showDebug(const char *string, ...) +static void showmsg_showDebug(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showDebug(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_DEBUG, string, ap); va_end(ap); } -void showmsg_showError(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showError(const char *string, ...) +static void showmsg_showError(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showError(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_ERROR, string, ap); va_end(ap); } -void showmsg_showFatalError(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showFatalError(const char *string, ...) +static void showmsg_showFatalError(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showFatalError(const char *string, ...) { va_list ap; va_start(ap, string); @@ -837,11 +841,11 @@ void showmsg_showFatalError(const char *string, ...) va_end(ap); } -void showmsg_init(void) +static void showmsg_init(void) { } -void showmsg_final(void) +static void showmsg_final(void) { } -- cgit v1.2.3-70-g09d2 From 2e89d5b2824801ed49c62db9f6743f32593018bc Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 24 Jun 2018 05:11:00 +0200 Subject: Fix some warnings caused by static functions defined and unused Signed-off-by: Haru --- src/common/showmsg.c | 2 ++ src/common/socket.c | 10 ++++------ src/common/strlib.c | 9 --------- 3 files changed, 6 insertions(+), 15 deletions(-) (limited to 'src/common/showmsg.c') diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 91f84e9d3..32d1e7610 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -739,6 +739,7 @@ static void showmsg_clearScreen(void) #endif } +#if 0 // Unused static int ShowMessage_(enum msg_type flag, const char *string, ...) __attribute__((format(printf, 2, 3))); static int ShowMessage_(enum msg_type flag, const char *string, ...) { @@ -749,6 +750,7 @@ static int ShowMessage_(enum msg_type flag, const char *string, ...) va_end(ap); return ret; } +#endif // Unused // direct printf replacement static void showmsg_showMessage(const char *string, ...) __attribute__((format(printf, 1, 2))); diff --git a/src/common/socket.c b/src/common/socket.c index 6119a5341..290c7a1b3 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -78,8 +78,6 @@ static struct socket_interface sockt_s; struct socket_interface *sockt; -static struct socket_data **session; - static const char *SOCKET_CONF_FILENAME = "conf/common/socket.conf"; #ifdef SEND_SHORTLIST @@ -1332,6 +1330,7 @@ static bool access_list_add(struct config_setting_t *setting, const char *list_n #endif // MINICORE ////////////////////////////// +#ifndef MINICORE /** * Reads 'socket_configuration/ip_rules' and initializes required variables. * @@ -1343,7 +1342,6 @@ static bool access_list_add(struct config_setting_t *setting, const char *list_n */ static bool socket_config_read_iprules(const char *filename, struct config_t *config, bool imported) { -#ifndef MINICORE struct config_setting_t *setting = NULL; const char *temp = NULL; @@ -1386,11 +1384,12 @@ static bool socket_config_read_iprules(const char *filename, struct config_t *co } else { access_list_add(setting, "deny_list", &access_deny); } -#endif // ! MINICORE return true; } +#endif // ! MINICORE +#ifndef MINICORE /** * Reads 'socket_configuration/ddos' and initializes required variables. * @@ -1402,7 +1401,6 @@ static bool socket_config_read_iprules(const char *filename, struct config_t *co */ static bool socket_config_read_ddos(const char *filename, struct config_t *config, bool imported) { -#ifndef MINICORE struct config_setting_t *setting = NULL; nullpo_retr(false, filename); @@ -1419,9 +1417,9 @@ static bool socket_config_read_ddos(const char *filename, struct config_t *confi libconfig->setting_lookup_int(setting, "count", &ddos_count); libconfig->setting_lookup_int(setting, "autoreset", &ddos_autoreset); -#endif // ! MINICORE return true; } +#endif // ! MINICORE /** * Reads 'socket_configuration' and initializes required variables. diff --git a/src/common/strlib.c b/src/common/strlib.c index c9448177b..ddb1eb78a 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -1137,17 +1137,8 @@ void strlib_defaults(void) strlib->normalize_name_ = strlib_normalize_name; strlib->stristr_ = strlib_stristr; -#if !(defined(WIN32) && defined(_MSC_VER)) && !defined(HAVE_STRNLEN) strlib->strnlen_ = strlib_strnlen; -#else - strlib->strnlen_ = NULL; -#endif - -#ifdef WIN32 strlib->strtok_r_ = strlib_strtok_r; -#else - strlib->strtok_r_ = NULL; -#endif strlib->e_mail_check_ = strlib_e_mail_check; strlib->config_switch_ = strlib_config_switch; -- cgit v1.2.3-70-g09d2