Fixed smartcard related scanbuild warnings.

This commit is contained in:
Armin Novak 2017-12-21 10:45:55 +01:00
parent 6a21bdae3d
commit bb7ba6ff26
3 changed files with 12 additions and 24 deletions

View File

@ -678,10 +678,8 @@ static UINT smartcard_irp_request(DEVICE* device, IRP* irp)
UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
size_t length;
RDPDR_SMARTCARD* device;
SMARTCARD_DEVICE* smartcard;
UINT error = CHANNEL_RC_NO_MEMORY;
device = (RDPDR_SMARTCARD*) pEntryPoints->device;
smartcard = (SMARTCARD_DEVICE*) calloc(1, sizeof(SMARTCARD_DEVICE));
if (!smartcard)
@ -706,7 +704,6 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
}
Stream_Write(smartcard->device.data, "SCARD", 6);
smartcard->IrpQueue = MessageQueue_New(NULL);
if (!smartcard->IrpQueue)

View File

@ -777,7 +777,6 @@ static LONG smartcard_ConnectA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERA
}
status = ret.ReturnCode;
out_fail:
free(call->szReader);
return status;
@ -836,7 +835,6 @@ static LONG smartcard_ConnectW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERA
}
status = ret.ReturnCode;
out_fail:
free(call->szReader);
return status;
@ -867,7 +865,7 @@ static LONG smartcard_Reconnect_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
Reconnect_Return ret;
IRP* irp = operation->irp;
Reconnect_Call* call = operation->call;
status = ret.ReturnCode = SCardReconnect(operation->hCard, call->dwShareMode,
ret.ReturnCode = SCardReconnect(operation->hCard, call->dwShareMode,
call->dwPreferredProtocols, call->dwInitialization, &ret.dwActiveProtocol);
smartcard_trace_reconnect_return(smartcard, &ret);
@ -1136,7 +1134,6 @@ static LONG smartcard_StatusW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
cchReaderLen = SCARD_AUTOALLOCATE;
cbAtrLen = call->cbAtrLen;
ZeroMemory(ret.pbAtr, 32);
status = ret.ReturnCode = SCardStatusW(operation->hCard,
call->fmszReaderNamesIsNULL ? NULL : (LPWSTR) &mszReaderNames,
@ -1152,6 +1149,7 @@ static LONG smartcard_StatusW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
if (call->cbAtrLen)
ret.cbAtrLen = cbAtrLen;
}
smartcard_trace_status_return(smartcard, &ret, TRUE);
if ((status = smartcard_pack_status_return(smartcard, irp->output, &ret)))
@ -1207,7 +1205,7 @@ static LONG smartcard_Transmit_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERA
}
ret.pioRecvPci = call->pioRecvPci;
status = ret.ReturnCode = SCardTransmit(operation->hCard, call->pioSendPci, call->pbSendBuffer,
ret.ReturnCode = SCardTransmit(operation->hCard, call->pioSendPci, call->pbSendBuffer,
call->cbSendLength, ret.pioRecvPci, ret.pbRecvBuffer, &(ret.cbRecvLength));
smartcard_trace_transmit_return(smartcard, &ret);
@ -1255,7 +1253,7 @@ static LONG smartcard_Control_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
if (!ret.pvOutBuffer)
return SCARD_E_NO_MEMORY;
status = ret.ReturnCode = SCardControl(operation->hCard,
ret.ReturnCode = SCardControl(operation->hCard,
call->dwControlCode, call->pvInBuffer, call->cbInBufferSize,
ret.pvOutBuffer, call->cbOutBufferSize, &ret.cbOutBufferSize);
smartcard_trace_control_return(smartcard, &ret);
@ -1314,7 +1312,7 @@ static LONG smartcard_GetAttrib_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
}
cbAttrLen = call->cbAttrLen;
status = ret.ReturnCode = SCardGetAttrib(operation->hCard, call->dwAttrId,
ret.ReturnCode = SCardGetAttrib(operation->hCard, call->dwAttrId,
autoAllocate ? (LPBYTE) & (ret.pbAttr) : ret.pbAttr, &cbAttrLen);
ret.cbAttrLen = cbAttrLen;
smartcard_trace_get_attrib_return(smartcard, &ret, call->dwAttrId);
@ -1396,7 +1394,6 @@ static LONG smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard,
SMARTCARD_OPERATION* operation)
{
LONG status;
BOOL equal;
DWORD i, j, k;
GetStatusChange_Return ret;
LPSCARD_READERSTATEA state = NULL;
@ -1429,24 +1426,18 @@ static LONG smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard,
{
for (j = 0; j < call->cReaders; j++)
{
equal = TRUE;
for (k = 0; k < call->rgAtrMasks[i].cbAtr; k++)
{
if ((call->rgAtrMasks[i].rgbAtr[k] & call->rgAtrMasks[i].rgbMask[k]) !=
(states[j].rgbAtr[k] & call->rgAtrMasks[i].rgbMask[k]))
{
equal = FALSE;
break;
}
if (equal)
{
states[j].dwEventState |= SCARD_STATE_ATRMATCH;
}
}
}
}
ret.cReaders = call->cReaders;
ret.rgReaderStates = NULL;

View File

@ -2761,7 +2761,7 @@ LONG smartcard_unpack_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard, wS
return STATUS_BUFFER_TOO_SMALL;
}
call->rgAtrMasks = (LocateCards_ATRMask*)calloc(call->cAtrs, sizeof(SCARD_ATRMASK));
call->rgAtrMasks = (LocateCards_ATRMask*)calloc(call->cAtrs, sizeof(LocateCards_ATRMask));
if (!call->rgAtrMasks)
{