Fixed scanbuild warnings.

This commit is contained in:
Armin Novak 2017-02-20 14:28:33 +01:00
parent c0671b49b4
commit e9b5d78673
3 changed files with 49 additions and 41 deletions

View File

@ -1046,8 +1046,6 @@ static INLINE UINT32 freerdp_bitmap_planar_compress_planes_rle(
outPlanes, &dstSizes[3]))
return 0;
outPlanes += dstSizes[3];
outPlanesSize -= dstSizes[3];
return 1;
}

View File

@ -97,7 +97,7 @@ static char* GetPath_TEMP(void)
#ifdef _WIN32
path = GetEnvAlloc("TEMP");
#elif defined(__IOS__)
path = ios_get_temp();
path = ios_get_temp();
#else
path = GetEnvAlloc("TMPDIR");
@ -366,7 +366,11 @@ char* GetEnvironmentPath(char* name)
if (!env)
return NULL;
nSize = GetEnvironmentVariableA(name, env, nSize);
if (GetEnvironmentVariableA(name, env, nSize) != nSize)
{
free(env);
return NULL;
}
}
return env;

View File

@ -73,9 +73,7 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
void* args[32];
char format[256];
SYSTEMTIME localTime;
GetLocalTime(&localTime);
index = 0;
p = (char*) layout->FormatString;
@ -104,7 +102,6 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
else if ((p[0] == 'f') && (p[1] == 'l')) /* file */
{
char* file;
file = strrchr(message->FileName, '/');
if (!file)
@ -129,14 +126,14 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
}
else if ((p[0] == 'l') && (p[1] == 'n')) /* line number */
{
args[argc++] = (void*) (size_t) message->LineNumber;
args[argc++] = (void*)(size_t) message->LineNumber;
format[index++] = '%';
format[index++] = 'u';
p++;
}
else if ((p[0] == 'p') && (p[1] == 'i') && (p[2] == 'd')) /* process id */
{
args[argc++] = (void*) (size_t) GetCurrentProcessId();
args[argc++] = (void*)(size_t) GetCurrentProcessId();
format[index++] = '%';
format[index++] = 'u';
p += 2;
@ -145,12 +142,12 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
{
#if defined __linux__ && !defined ANDROID
/* On Linux we prefer to see the LWP id */
args[argc++] = (void*) (size_t) syscall(SYS_gettid);;
args[argc++] = (void*)(size_t) syscall(SYS_gettid);;
format[index++] = '%';
format[index++] = 'l';
format[index++] = 'd';
#else
args[argc++] = (void*) (size_t) GetCurrentThreadId();
args[argc++] = (void*)(size_t) GetCurrentThreadId();
format[index++] = '%';
format[index++] = '0';
format[index++] = '8';
@ -160,14 +157,14 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
}
else if ((p[0] == 'y') && (p[1] == 'r')) /* year */
{
args[argc++] = (void*) (size_t) localTime.wYear;
args[argc++] = (void*)(size_t) localTime.wYear;
format[index++] = '%';
format[index++] = 'u';
p++;
}
else if ((p[0] == 'm') && (p[1] == 'o')) /* month */
{
args[argc++] = (void*) (size_t) localTime.wMonth;
args[argc++] = (void*)(size_t) localTime.wMonth;
format[index++] = '%';
format[index++] = '0';
format[index++] = '2';
@ -176,7 +173,7 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
}
else if ((p[0] == 'd') && (p[1] == 'w')) /* day of week */
{
args[argc++] = (void*) (size_t) localTime.wDayOfWeek;
args[argc++] = (void*)(size_t) localTime.wDayOfWeek;
format[index++] = '%';
format[index++] = '0';
format[index++] = '2';
@ -185,7 +182,7 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
}
else if ((p[0] == 'd') && (p[1] == 'y')) /* day */
{
args[argc++] = (void*) (size_t) localTime.wDay;
args[argc++] = (void*)(size_t) localTime.wDay;
format[index++] = '%';
format[index++] = '0';
format[index++] = '2';
@ -194,7 +191,7 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
}
else if ((p[0] == 'h') && (p[1] == 'r')) /* hours */
{
args[argc++] = (void*) (size_t) localTime.wHour;
args[argc++] = (void*)(size_t) localTime.wHour;
format[index++] = '%';
format[index++] = '0';
format[index++] = '2';
@ -203,7 +200,7 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
}
else if ((p[0] == 'm') && (p[1] == 'i')) /* minutes */
{
args[argc++] = (void*) (size_t) localTime.wMinute;
args[argc++] = (void*)(size_t) localTime.wMinute;
format[index++] = '%';
format[index++] = '0';
format[index++] = '2';
@ -212,7 +209,7 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
}
else if ((p[0] == 's') && (p[1] == 'e')) /* seconds */
{
args[argc++] = (void*) (size_t) localTime.wSecond;
args[argc++] = (void*)(size_t) localTime.wSecond;
format[index++] = '%';
format[index++] = '0';
format[index++] = '2';
@ -221,7 +218,7 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
}
else if ((p[0] == 'm') && (p[1] == 'l')) /* milliseconds */
{
args[argc++] = (void*) (size_t) localTime.wMilliseconds;
args[argc++] = (void*)(size_t) localTime.wMilliseconds;
format[index++] = '%';
format[index++] = '0';
format[index++] = '3';
@ -264,78 +261,77 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, wLogMessage* me
case 5:
WLog_PrintMessagePrefix(log, message, format, args[0], args[1], args[2], args[3],
args[4]);
args[4]);
break;
case 6:
WLog_PrintMessagePrefix(log, message, format, args[0], args[1], args[2], args[3],
args[4], args[5]);
args[4], args[5]);
break;
case 7:
WLog_PrintMessagePrefix(log, message, format, args[0], args[1], args[2], args[3],
args[4], args[5], args[6]);
args[4], args[5], args[6]);
break;
case 8:
WLog_PrintMessagePrefix(log, message, format, args[0], args[1], args[2], args[3],
args[4], args[5], args[6], args[7]);
args[4], args[5], args[6], args[7]);
break;
case 9:
WLog_PrintMessagePrefix(log, message, format, args[0], args[1], args[2], args[3],
args[4], args[5], args[6], args[7], args[8]);
args[4], args[5], args[6], args[7], args[8]);
break;
case 10:
WLog_PrintMessagePrefix(log, message, format, args[0], args[1], args[2], args[3],
args[4], args[5], args[6], args[7], args[8], args[9]);
args[4], args[5], args[6], args[7], args[8], args[9]);
break;
case 11:
WLog_PrintMessagePrefix(log, message, format, args[0], args[1], args[2], args[3],
args[4], args[5], args[6], args[7], args[8], args[9], args[10]);
args[4], args[5], args[6], args[7], args[8], args[9], args[10]);
break;
case 12:
WLog_PrintMessagePrefix(log, message, format, args[0], args[1], args[2], args[3],
args[4], args[5], args[6], args[7], args[8], args[9], args[10],
args[11]);
args[4], args[5], args[6], args[7], args[8], args[9], args[10],
args[11]);
break;
case 13:
WLog_PrintMessagePrefix(log, message, format, args[0], args[1], args[2], args[3],
args[4], args[5], args[6], args[7], args[8], args[9], args[10],
args[11], args[12]);
args[4], args[5], args[6], args[7], args[8], args[9], args[10],
args[11], args[12]);
break;
case 14:
WLog_PrintMessagePrefix(log, message, format, args[0], args[1], args[2], args[3],
args[4], args[5], args[6], args[7], args[8], args[9], args[10],
args[11], args[12], args[13]);
args[4], args[5], args[6], args[7], args[8], args[9], args[10],
args[11], args[12], args[13]);
break;
case 15:
WLog_PrintMessagePrefix(log, message, format, args[0], args[1], args[2], args[3],
args[4], args[5], args[6], args[7], args[8], args[9], args[10],
args[11], args[12], args[13], args[14]);
args[4], args[5], args[6], args[7], args[8], args[9], args[10],
args[11], args[12], args[13], args[14]);
break;
case 16:
WLog_PrintMessagePrefix(log, message, format, args[0], args[1], args[2], args[3],
args[4], args[5], args[6], args[7], args[8], args[9], args[10],
args[11], args[12], args[13], args[14], args[15]);
args[4], args[5], args[6], args[7], args[8], args[9], args[10],
args[11], args[12], args[13], args[14], args[15]);
break;
}
return TRUE;
}
wLogLayout* WLog_GetLogLayout(wLog* log)
{
wLogAppender* appender;
appender = WLog_GetLogAppender(log);
return appender->Layout;
}
@ -347,9 +343,11 @@ BOOL WLog_Layout_SetPrefixFormat(wLog* log, wLogLayout* layout, const char* form
if (format)
{
layout->FormatString = _strdup(format);
if (!layout->FormatString)
return FALSE;
}
return TRUE;
}
@ -358,21 +356,29 @@ wLogLayout* WLog_Layout_New(wLog* log)
DWORD nSize;
char* env = NULL;
wLogLayout* layout;
layout = (wLogLayout*) calloc(1, sizeof(wLogLayout));
if (!layout)
return NULL;
nSize = GetEnvironmentVariableA("WLOG_PREFIX", NULL, 0);
if (nSize)
{
env = (LPSTR) malloc(nSize);
if (!env)
{
free(layout);
return NULL;
}
nSize = GetEnvironmentVariableA("WLOG_PREFIX", env, nSize);
if (GetEnvironmentVariableA("WLOG_PREFIX", env, nSize) != nSize)
{
free(env);
free(layout);
return NULL;
}
}
if (env)
@ -384,6 +390,7 @@ wLogLayout* WLog_Layout_New(wLog* log)
#else
layout->FormatString = _strdup("[%hr:%mi:%se:%ml] [%pid:%tid] [%lv][%mn] - ");
#endif
if (!layout->FormatString)
{
free(layout);
@ -391,7 +398,6 @@ wLogLayout* WLog_Layout_New(wLog* log)
}
}
return layout;
}