From 4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4 Mon Sep 17 00:00:00 2001 From: Haru Date: Tue, 20 Jan 2015 04:36:08 +0100 Subject: 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 --- src/common/strlib.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/common/strlib.c') 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); -- cgit v1.2.3-70-g09d2