summaryrefslogtreecommitdiff
path: root/src/common/strlib.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-01-20 04:36:08 +0100
committerHaru <haru@dotalux.com>2015-01-20 04:41:33 +0100
commit4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4 (patch)
treedab9d12a6a4b95a37598e27e6e86d6047360d61b /src/common/strlib.c
parent03709c136ad300be631adfd38dc36c2433bda718 (diff)
downloadhercules-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/strlib.c')
-rw-r--r--src/common/strlib.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/common/strlib.c b/src/common/strlib.c
index 8b63b4161..b5fcff576 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -946,7 +946,6 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc
char** fields; // buffer for fields ([0] is reserved)
int columns, fields_length;
char path[1024], line[1024];
- char* match;
snprintf(path, sizeof(path), "%s/%s", directory, filename);
@@ -962,9 +961,11 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc
// process rows one by one
while( fgets(line, sizeof(line), fp) ) {
+ char *match;
lines++;
- if( ( match = strstr(line, "//") ) != NULL ) {// strip comments
+ if ((match = strstr(line, "//") ) != NULL) {
+ // strip comments
match[0] = 0;
}
@@ -1039,13 +1040,11 @@ int StringBuf_Printf(StringBuf *self, const char *fmt, ...) {
/// Appends the result of vprintf to the StringBuf
int StringBuf_Vprintf(StringBuf* self, const char* fmt, va_list ap) {
- int n, off;
- size_t size;
-
for(;;) {
va_list apcopy;
+ int n, off;
/* Try to print in the allocated space. */
- size = self->max_ - (self->ptr_ - self->buf_);
+ size_t size = self->max_ - (self->ptr_ - self->buf_);
va_copy(apcopy, ap);
n = vsnprintf(self->ptr_, size, fmt, apcopy);
va_end(apcopy);