Fix some static analizer warnings

This commit is contained in:
asapelkin 2019-10-16 19:49:24 +03:00 committed by akallabeth
parent 40463bb2f2
commit 82eadad4a4
17 changed files with 56 additions and 78 deletions

View File

@ -173,9 +173,9 @@ static DWORD WINAPI rdpei_schedule_thread(LPVOID arg)
{
DWORD status;
RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) arg;
RdpeiClientContext* context = (RdpeiClientContext*) rdpei->iface.pInterface;
HANDLE hdl[] = {rdpei->event, rdpei->stopEvent};
UINT error = CHANNEL_RC_OK;
RdpeiClientContext* context;
HANDLE hdl[2];
if (!rdpei)
{
@ -183,6 +183,10 @@ static DWORD WINAPI rdpei_schedule_thread(LPVOID arg)
goto out;
}
context = (RdpeiClientContext*) rdpei->iface.pInterface;
hdl[0] = rdpei->event;
hdl[1] = rdpei->stopEvent;
if (!context)
{
error = ERROR_INVALID_PARAMETER;

View File

@ -122,7 +122,7 @@ static UINT xf_UpdateSurfaces(RdpgfxClientContext* context)
UINT status = CHANNEL_RC_OK;
UINT16* pSurfaceIds = NULL;
rdpGdi* gdi = (rdpGdi*)context->custom;
xfContext* xfc = (xfContext*) gdi->context;
xfContext* xfc;
if (!gdi)
return status;
@ -133,6 +133,7 @@ static UINT xf_UpdateSurfaces(RdpgfxClientContext* context)
if (gdi->suppressOutput)
return CHANNEL_RC_OK;
xfc = (xfContext*) gdi->context;
EnterCriticalSection(&context->mux);
context->GetSurfaceIds(context, &pSurfaceIds, &count);

View File

@ -453,9 +453,6 @@ static BOOL update_gdi_fast_glyph(rdpContext* context,
rdpGlyph* glyph;
const GLYPH_DATA_V2* glyphData = &fastGlyph->glyphData;
if (!glyphData)
return FALSE;
glyph = Glyph_Alloc(context, glyphData->x, glyphData->y, glyphData->cx,
glyphData->cy,
glyphData->cb, glyphData->aj);
@ -727,30 +724,27 @@ void glyph_cache_free(rdpGlyphCache* glyphCache)
int i;
GLYPH_CACHE* cache = glyphCache->glyphCache;
if (cache)
for (i = 0; i < 10; i++)
{
for (i = 0; i < 10; i++)
UINT32 j;
rdpGlyph** entries = cache[i].entries;
if (!entries)
continue;
for (j = 0; j < cache[i].number; j++)
{
UINT32 j;
rdpGlyph** entries = cache[i].entries;
rdpGlyph* glyph = entries[j];
if (!entries)
continue;
for (j = 0; j < cache[i].number; j++)
if (glyph)
{
rdpGlyph* glyph = entries[j];
if (glyph)
{
glyph->Free(glyphCache->context, glyph);
entries[j] = NULL;
}
glyph->Free(glyphCache->context, glyph);
entries[j] = NULL;
}
free(entries);
cache[i].entries = NULL;
}
free(entries);
cache[i].entries = NULL;
}
if (glyphCache->fragCache.entries)

View File

@ -1000,13 +1000,15 @@ BOOL rfx_process_message(RFX_CONTEXT* context, const BYTE* data, UINT32 length,
REGION16 updateRegion;
UINT32 blockLen;
UINT32 blockType;
RFX_MESSAGE* message = &context->currentMessage;
wStream inStream, *s = &inStream;
BOOL ok = TRUE;
RFX_MESSAGE* message;
if (!context || !data || !length)
return FALSE;
message = &context->currentMessage;
Stream_StaticInit(s, (BYTE*)data, length);
message->freeRects = TRUE;

View File

@ -874,8 +874,7 @@ static int xcrush_compress_l1(XCRUSH_CONTEXT* xcrush, BYTE* pSrcData, UINT32 Src
if (status < 0)
return status;
if (status > 0)
Flags |= L1_COMPRESSED;
Flags |= L1_COMPRESSED;
}
}
}

View File

@ -563,9 +563,6 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* pas
if (!pbIn || !pbOut)
goto fail;
if ((EncryptedSize == 0) || (cbPassStubW > UINT32_MAX))
goto fail;
*((UINT32*) pbIn) = (UINT32)cbPassStubW;
CopyMemory(&pbIn[4], PassStubW, cbPassStubW);
rc4Ctx = winpr_Cipher_New(WINPR_CIPHER_ARC4_128, WINPR_ENCRYPT,

View File

@ -678,7 +678,10 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelInitEx(LPVOID lpUserParam, LPVOID cl
if (!pInitHandle)
return CHANNEL_RC_BAD_INIT_HANDLE;
if (!pChannel || (channelCount <= 0) || !pChannelInitEventProcEx)
if (!pChannel)
return CHANNEL_RC_BAD_CHANNEL;
if ((channelCount <= 0) || !pChannelInitEventProcEx)
return CHANNEL_RC_INITIALIZATION_ERROR;
pChannelInitData = (CHANNEL_INIT_DATA*) pInitHandle;
@ -691,9 +694,6 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelInitEx(LPVOID lpUserParam, LPVOID cl
if ((channels->openDataCount + channelCount) > CHANNEL_MAX_COUNT)
return CHANNEL_RC_TOO_MANY_CHANNELS;
if (!pChannel)
return CHANNEL_RC_BAD_CHANNEL;
if (channels->connected)
return CHANNEL_RC_ALREADY_CONNECTED;
@ -763,7 +763,10 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelInit(LPVOID* ppInitHandle,
if (!ppInitHandle || !channels)
return CHANNEL_RC_BAD_INIT_HANDLE;
if (!pChannel || (channelCount <= 0) || !pChannelInitEventProc)
if (!pChannel)
return CHANNEL_RC_BAD_CHANNEL;
if ((channelCount <= 0) || !pChannelInitEventProc)
return CHANNEL_RC_INITIALIZATION_ERROR;
pInterface = g_pInterface;
@ -779,9 +782,6 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelInit(LPVOID* ppInitHandle,
if (channels->openDataCount + channelCount > CHANNEL_MAX_COUNT)
return CHANNEL_RC_TOO_MANY_CHANNELS;
if (!pChannel)
return CHANNEL_RC_BAD_CHANNEL;
if (channels->connected)
return CHANNEL_RC_ALREADY_CONNECTED;

View File

@ -406,9 +406,6 @@ BOOL freerdp_check_event_handles(rdpContext* context)
return FALSE;
}
if (!status)
return FALSE;
status = checkChannelErrorEvent(context);
if (!status)

View File

@ -220,6 +220,12 @@ BOOL ntlm_authenticate(rdpNtlm* ntlm, BOOL* pbContinueNeeded)
{
SECURITY_STATUS status;
if ((!ntlm) || (!ntlm->table))
{
WLog_ERR(TAG, "ntlm_authenticate: invalid ntlm context");
return FALSE;
}
if (ntlm->outputBuffer[0].pvBuffer)
{
free(ntlm->outputBuffer[0].pvBuffer);
@ -252,12 +258,6 @@ BOOL ntlm_authenticate(rdpNtlm* ntlm, BOOL* pbContinueNeeded)
}
}
if ((!ntlm) || (!ntlm->table))
{
WLog_ERR(TAG, "ntlm_authenticate: invalid ntlm context");
return FALSE;
}
status = ntlm->table->InitializeSecurityContext(&ntlm->credentials,
(ntlm->haveContext) ? &ntlm->context : NULL,
(ntlm->ServicePrincipalName) ? ntlm->ServicePrincipalName : NULL,

View File

@ -172,7 +172,7 @@ static BOOL rdp_read_server_auto_reconnect_cookie(rdpRdp* rdp, wStream* s, logon
info->LogonId = autoReconnectCookie->logonId;
CopyMemory(info->ArcRandomBits, p, 16);
if ((settings->PrintReconnectCookie) && (autoReconnectCookie->cbLen > 0))
if ((settings->PrintReconnectCookie))
{
char* base64;
base64 = crypto_base64_encode((BYTE*) autoReconnectCookie, sizeof(ARC_SC_PRIVATE_PACKET));
@ -777,15 +777,8 @@ static void rdp_write_info_packet(rdpRdp* rdp, wStream* s)
/* excludes (!) the length of the mandatory null terminator */
cbDomain = cbDomain >= 2 ? cbDomain - 2 : cbDomain;
if (!settings->RemoteAssistanceMode)
{
cbUserName = ConvertToUnicode(CP_UTF8, 0, settings->Username, -1, &userNameW, 0) * 2;
}
else
{
/* user name provided by the expert for connecting to the novice computer */
cbUserName = ConvertToUnicode(CP_UTF8, 0, settings->Username, -1, &userNameW, 0) * 2;
}
/* user name provided by the expert for connecting to the novice computer */
cbUserName = ConvertToUnicode(CP_UTF8, 0, settings->Username, -1, &userNameW, 0) * 2;
/* excludes (!) the length of the mandatory null terminator */
cbUserName = cbUserName >= 2 ? cbUserName - 2 : cbUserName;

View File

@ -914,7 +914,7 @@ BOOL nego_send_negotiation_request(rdpNego* nego)
length += 8;
}
if ((length < 5) || (length > UINT16_MAX))
if (length > UINT16_MAX)
goto fail;
em = Stream_GetPosition(s);

View File

@ -490,9 +490,10 @@ static int recv_socks_reply(BIO* bufferedBio, BYTE* buf, int len, char* reason,
status = BIO_read(bufferedBio, buf, len);
if (status > 0)
{
break;
if (status < 0)
}
else if (status < 0)
{
/* Error? */
if (BIO_should_retry(bufferedBio))
@ -504,8 +505,7 @@ static int recv_socks_reply(BIO* bufferedBio, BYTE* buf, int len, char* reason,
WLog_ERR(TAG, "Failed reading %s reply from SOCKS proxy (Status %d)", reason, status);
return -1;
}
if (status == 0)
else // if (status == 0)
{
/* Error? */
WLog_ERR(TAG, "Failed reading %s reply from SOCKS proxy (BIO_read returned zero)", reason);

View File

@ -562,7 +562,7 @@ SSIZE_T transport_read_layer(rdpTransport* transport, BYTE* data, size_t bytes)
{
const SSIZE_T tr = (SSIZE_T)bytes - read;
int r = (int)((tr > INT_MAX) ? INT_MAX : tr);
int status = status = BIO_read(transport->frontBio, data + read, r);
int status = BIO_read(transport->frontBio, data + read, r);
if (status <= 0)
{

View File

@ -68,10 +68,7 @@ static BOOL certificate_line_is_comment(const char* line, size_t length)
}
}
if (length < 1)
return TRUE;
return FALSE;
return TRUE;
}
BOOL certificate_store_init(rdpCertificateStore* certificate_store)

View File

@ -546,7 +546,6 @@ static UINT gdi_SurfaceCommand_AVC444(rdpGdi* gdi, RdpgfxClientContext* context,
RDPGFX_H264_METABLOCK* meta1;
RDPGFX_AVC420_BITMAP_STREAM* avc2;
RDPGFX_H264_METABLOCK* meta2;
RECTANGLE_16* regionRects = NULL;
surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
if (!surface)
@ -626,7 +625,6 @@ static UINT gdi_SurfaceCommand_AVC444(rdpGdi* gdi, RdpgfxClientContext* context,
}
fail:
free(regionRects);
return status;
#else
return ERROR_NOT_SUPPORTED;
@ -880,11 +878,13 @@ static UINT gdi_SurfaceCommand(RdpgfxClientContext* context,
const RDPGFX_SURFACE_COMMAND* cmd)
{
UINT status = CHANNEL_RC_OK;
rdpGdi* gdi = (rdpGdi*) context->custom;
rdpGdi* gdi;
if (!context || !cmd)
return ERROR_INVALID_PARAMETER;
gdi = (rdpGdi*) context->custom;
EnterCriticalSection(&context->mux);
WLog_Print(gdi->log, WLOG_TRACE,
"surfaceId=%"PRIu32", codec=%"PRIu32", contextId=%"PRIu32", format=%s, "
@ -998,7 +998,7 @@ static UINT gdi_CreateSurface(RdpgfxClientContext* context,
default:
free(surface);
return ERROR_INTERNAL_ERROR;
goto fail;
}
surface->scanline = gfx_align_scanline(surface->width * 4, 16);

View File

@ -1462,13 +1462,6 @@ static BOOL _wait_on_mask(WINPR_COMM *pComm, ULONG *pOutputMask)
Sleep(100); /* 100 ms */
}
CommLog_Print(WLOG_WARN, "_wait_on_mask, unexpected return, WaitEventMask=0x%08"PRIX32"", pComm->WaitEventMask);
EnterCriticalSection(&pComm->EventsLock);
pComm->PendingEvents &= ~SERIAL_EV_FREERDP_WAITING;
LeaveCriticalSection(&pComm->EventsLock);
assert(FALSE);
return FALSE;
}
static BOOL _set_break_on(WINPR_COMM *pComm)

View File

@ -81,6 +81,7 @@ DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer)
}
memcpy(lpBuffer, cwd, length + 1);
free(cwd);
return length;
}