Unify std::vector::data() typecasting
When used in place of void*, typecasting is redundant. In other situations use reinterpret_cast<true type>() rather than C-style typecasting. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
83c749e394
commit
49b55331e4
@ -68,7 +68,7 @@ static _Success_(return != 0) BOOL WINAPI CertGetCertificateContextProperty(_In_
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (GetLastError() == ERROR_MORE_DATA) {
|
} else if (GetLastError() == ERROR_MORE_DATA) {
|
||||||
aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
||||||
if (CertGetCertificateContextProperty(pCertContext, dwPropId, (BYTE*)aData.data(), &dwSize))
|
if (CertGetCertificateContextProperty(pCertContext, dwPropId, aData.data(), &dwSize))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ static _Success_(return != 0) BOOL CryptGetHashParam(_In_ HCRYPTHASH hHash, _In_
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (GetLastError() == ERROR_MORE_DATA) {
|
} else if (GetLastError() == ERROR_MORE_DATA) {
|
||||||
aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
||||||
if (CryptGetHashParam(hHash, dwParam, (BYTE*)aData.data(), &dwSize, dwFlags))
|
if (CryptGetHashParam(hHash, dwParam, reinterpret_cast<BYTE*>(aData.data()), &dwSize, dwFlags))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ static _Success_(return != 0) BOOL CryptGetKeyParam(_In_ HCRYPTKEY hKey, _In_ DW
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (GetLastError() == ERROR_MORE_DATA) {
|
} else if (GetLastError() == ERROR_MORE_DATA) {
|
||||||
aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
||||||
if (CryptGetKeyParam(hKey, dwParam, (BYTE*)aData.data(), &dwSize, dwFlags))
|
if (CryptGetKeyParam(hKey, dwParam, reinterpret_cast<BYTE*>(aData.data()), &dwSize, dwFlags))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ static _Success_(return != 0) BOOL CryptExportKey(_In_ HCRYPTKEY hKey, _In_ HCRY
|
|||||||
|
|
||||||
if (CryptExportKey(hKey, hExpKey, dwBlobType, dwFlags, NULL, &dwKeyBLOBSize)) {
|
if (CryptExportKey(hKey, hExpKey, dwBlobType, dwFlags, NULL, &dwKeyBLOBSize)) {
|
||||||
aData.resize((dwKeyBLOBSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
aData.resize((dwKeyBLOBSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
||||||
if (CryptExportKey(hKey, hExpKey, dwBlobType, dwFlags, aData.data(), &dwKeyBLOBSize))
|
if (CryptExportKey(hKey, hExpKey, dwBlobType, dwFlags, reinterpret_cast<BYTE*>(aData.data()), &dwKeyBLOBSize))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ static _Success_(return != 0) BOOL CryptEncrypt(_In_ HCRYPTKEY hKey, _In_opt_ HC
|
|||||||
|
|
||||||
if (dwBufLen) {
|
if (dwBufLen) {
|
||||||
aData.resize(dwBufLen);
|
aData.resize(dwBufLen);
|
||||||
if (CryptEncrypt(hKey, hHash, Final, dwFlags, (BYTE*)aData.data(), &dwEncLen, dwBufLen)) {
|
if (CryptEncrypt(hKey, hHash, Final, dwFlags, reinterpret_cast<BYTE*>(aData.data()), &dwEncLen, dwBufLen)) {
|
||||||
// Encryption succeeded.
|
// Encryption succeeded.
|
||||||
assert(dwEncLen <= dwBufLen);
|
assert(dwEncLen <= dwBufLen);
|
||||||
if (dwEncLen < dwBufLen)
|
if (dwEncLen < dwBufLen)
|
||||||
@ -203,7 +203,7 @@ static _Success_(return != 0) BOOL CryptEncrypt(_In_ HCRYPTKEY hKey, _In_opt_ HC
|
|||||||
// Encrypted data will be longer. Reserve more space and retry.
|
// Encrypted data will be longer. Reserve more space and retry.
|
||||||
aData.resize(((dwBufLen = dwEncLen) + sizeof(_Ty) - 1) / sizeof(_Ty));
|
aData.resize(((dwBufLen = dwEncLen) + sizeof(_Ty) - 1) / sizeof(_Ty));
|
||||||
dwEncLen = dwDataLen;
|
dwEncLen = dwDataLen;
|
||||||
if (CryptEncrypt(hKey, hHash, Final, dwFlags, (BYTE*)aData.data(), &dwEncLen, dwBufLen)) {
|
if (CryptEncrypt(hKey, hHash, Final, dwFlags, reinterpret_cast<BYTE*>(aData.data()), &dwEncLen, dwBufLen)) {
|
||||||
// Encryption succeeded.
|
// Encryption succeeded.
|
||||||
assert(dwEncLen <= dwBufLen);
|
assert(dwEncLen <= dwBufLen);
|
||||||
if (dwEncLen < dwBufLen)
|
if (dwEncLen < dwBufLen)
|
||||||
@ -228,7 +228,7 @@ static _Success_(return != 0) BOOL CryptDecrypt(_In_ HCRYPTKEY hKey, _In_opt_ HC
|
|||||||
{
|
{
|
||||||
DWORD dwDataLen = (DWORD)(aData.size() * sizeof(_Ty));
|
DWORD dwDataLen = (DWORD)(aData.size() * sizeof(_Ty));
|
||||||
|
|
||||||
if (CryptDecrypt(hKey, hHash, Final, dwFlags, (BYTE*)aData.data(), &dwDataLen)) {
|
if (CryptDecrypt(hKey, hHash, Final, dwFlags, reinterpret_cast<BYTE*>(aData.data()), &dwDataLen)) {
|
||||||
// Decryption succeeded.
|
// Decryption succeeded.
|
||||||
aData.resize((dwDataLen + sizeof(_Ty) - 1) / sizeof(_Ty));
|
aData.resize((dwDataLen + sizeof(_Ty) - 1) / sizeof(_Ty));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -40,7 +40,7 @@ static _Success_(return == ERROR_SUCCESS) ULONG TdhGetProperty(_In_ PEVENT_RECOR
|
|||||||
if (ulSize) {
|
if (ulSize) {
|
||||||
// Query property value.
|
// Query property value.
|
||||||
aData.resize((ulSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
aData.resize((ulSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
||||||
ulResult = TdhGetProperty(pEvent, TdhContextCount, pTdhContext, PropertyDataCount, pPropertyData, ulSize, reinterpret_cast<LPBYTE>(aData.data()));
|
ulResult = TdhGetProperty(pEvent, TdhContextCount, pTdhContext, PropertyDataCount, pPropertyData, ulSize, reinterpret_cast<PBYTE>(aData.data()));
|
||||||
} else {
|
} else {
|
||||||
// Property value size is zero.
|
// Property value size is zero.
|
||||||
aData.clear();
|
aData.clear();
|
||||||
|
@ -550,7 +550,7 @@ static LSTATUS RegQueryValueExA(_In_ HKEY hKey, _In_opt_z_ LPCSTR lpValueName, _
|
|||||||
} else if (lResult == ERROR_MORE_DATA) {
|
} else if (lResult == ERROR_MORE_DATA) {
|
||||||
// Allocate buffer on heap and retry.
|
// Allocate buffer on heap and retry.
|
||||||
aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
||||||
lResult = RegQueryValueExA(hKey, lpValueName, lpReserved, NULL, aData.data(), &dwSize);
|
lResult = RegQueryValueExA(hKey, lpValueName, lpReserved, NULL, reinterpret_cast<LPBYTE>(aData.data()), &dwSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return lResult;
|
return lResult;
|
||||||
@ -577,7 +577,7 @@ static LSTATUS RegQueryValueExW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR lpValueName,
|
|||||||
} else if (lResult == ERROR_MORE_DATA) {
|
} else if (lResult == ERROR_MORE_DATA) {
|
||||||
// Allocate buffer on heap and retry.
|
// Allocate buffer on heap and retry.
|
||||||
aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
|
||||||
lResult = RegQueryValueExW(hKey, lpValueName, lpReserved, NULL, aData.data(), &dwSize);
|
lResult = RegQueryValueExW(hKey, lpValueName, lpReserved, NULL, reinterpret_cast<LPBYTE>(aData.data()), &dwSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return lResult;
|
return lResult;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user