diff options
author | Haru <haru@dotalux.com> | 2015-01-20 04:36:08 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2015-01-20 04:41:33 +0100 |
commit | 4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4 (patch) | |
tree | dab9d12a6a4b95a37598e27e6e86d6047360d61b /src/common/HPM.c | |
parent | 03709c136ad300be631adfd38dc36c2433bda718 (diff) | |
download | hercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.tar.gz hercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.tar.bz2 hercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.tar.xz hercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.zip |
Minor fixes and tweaks suggested by cppcheck
- Variable scopes reduced
- Parenthesized ambiguous expressions
- Removed or added NULL checks where (un)necessary
- Corrected format strings
- Fixed typos potentially leading to bugs
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common/HPM.c')
-rw-r--r-- | src/common/HPM.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c index 10208cdad..25ca5441d 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -95,7 +95,6 @@ struct hplugin *hplugin_create(void) { } #define HPM_POP(x) { #x , x } bool hplugin_populate(struct hplugin *plugin, const char *filename) { - void **Link; struct { const char* name; void *Ref; @@ -113,7 +112,8 @@ bool hplugin_populate(struct hplugin *plugin, const char *filename) { int i, length = ARRAYLENGTH(ToLink); for(i = 0; i < length; i++) { - if( !( Link = plugin_import(plugin->dll, ToLink[i].name,void **) ) ) { + void **Link; + if (!( Link = plugin_import(plugin->dll, ToLink[i].name,void **))) { ShowWarning("HPM:plugin_load: failed to retrieve '%s' for '"CL_WHITE"%s"CL_RESET"', skipping...\n", ToLink[i].name, filename); HPM->unload(plugin); return false; @@ -268,7 +268,7 @@ struct hplugin *hplugin_load(const char* filename) { } void hplugin_unload(struct hplugin* plugin) { - unsigned int i = plugin->idx, cursor = 0; + unsigned int i = plugin->idx; if( plugin->filename ) aFree(plugin->filename); @@ -277,7 +277,8 @@ void hplugin_unload(struct hplugin* plugin) { /* TODO: for manual packet unload */ /* - Go through known packets and unlink any belonging to the plugin being removed */ aFree(plugin); - if( !HPM->off ) { + if (!HPM->off) { + int cursor = 0; HPM->plugins[i] = NULL; for(i = 0; i < HPM->plugin_count; i++) { if( HPM->plugins[i] == NULL ) @@ -838,14 +839,13 @@ void hpm_init(void) { #endif return; } -void hpm_memdown(void) { - unsigned int i; - +void hpm_memdown(void) +{ /* this memory is handled outside of the server's memory manager and thus cleared after memory manager goes down */ - if (HPM->fnames) - { - for( i = 0; i < HPM->fnamec; i++ ) { + if (HPM->fnames) { + unsigned int i; + for (i = 0; i < HPM->fnamec; i++) { free(HPM->fnames[i].name); } free(HPM->fnames); |