[warnings] use ARRAYSIZE macro

This commit is contained in:
akallabeth 2024-09-03 12:31:24 +02:00
parent baa70d1ab6
commit f3d84d4557
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
3 changed files with 19 additions and 29 deletions

View File

@ -334,7 +334,6 @@ static int xcrush_find_next_matching_chunk(XCRUSH_CONTEXT* WINPR_RESTRICT xcrush
XCRUSH_CHUNK* WINPR_RESTRICT chunk,
XCRUSH_CHUNK** WINPR_RESTRICT pNextChunk)
{
UINT32 index = 0;
XCRUSH_CHUNK* next = NULL;
WINPR_ASSERT(xcrush);
@ -344,7 +343,7 @@ static int xcrush_find_next_matching_chunk(XCRUSH_CONTEXT* WINPR_RESTRICT xcrush
if (chunk->next)
{
index = (chunk - xcrush->Chunks) / sizeof(XCRUSH_CHUNK);
UINT32 index = (chunk - xcrush->Chunks) / sizeof(XCRUSH_CHUNK);
if (index >= 65534)
return -4002; /* error */

View File

@ -1925,7 +1925,7 @@ static BOOL rdg_process_control_packet(rdpRdg* rdg, int type, size_t packetLengt
static int rdg_read_data_packet(rdpRdg* rdg, BYTE* buffer, int size)
{
RdgPacketHeader header;
RdgPacketHeader header = { 0 };
size_t readCount = 0;
size_t readSize = 0;
int status = 0;

View File

@ -987,7 +987,7 @@ void sspi_GlobalFinish(void)
static const SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameA(const SEC_CHAR* Name)
{
size_t cPackages = sizeof(SecPkgInfoA_LIST) / sizeof(*(SecPkgInfoA_LIST));
size_t cPackages = ARRAYSIZE(SecPkgInfoA_LIST);
for (size_t index = 0; index < cPackages; index++)
{
@ -1002,7 +1002,7 @@ static const SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameA(const
static const SecurityFunctionTableW* sspi_GetSecurityFunctionTableWByNameW(const SEC_WCHAR* Name)
{
size_t cPackages = sizeof(SecPkgInfoW_LIST) / sizeof(*(SecPkgInfoW_LIST));
size_t cPackages = ARRAYSIZE(SecPkgInfoW_LIST);
for (size_t index = 0; index < cPackages; index++)
{
@ -1073,12 +1073,10 @@ static void sspi_ContextBufferFree(void* contextBuffer)
static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesW(ULONG* pcPackages,
PSecPkgInfoW* ppPackageInfo)
{
size_t size = 0;
UINT32 cPackages = 0;
SecPkgInfoW* pPackageInfo = NULL;
cPackages = sizeof(SecPkgInfoW_LIST) / sizeof(*(SecPkgInfoW_LIST));
size = sizeof(SecPkgInfoW) * cPackages;
pPackageInfo = (SecPkgInfoW*)sspi_ContextBufferAlloc(EnumerateSecurityPackagesIndex, size);
size_t cPackages = ARRAYSIZE(SecPkgInfoW_LIST);
size_t size = sizeof(SecPkgInfoW) * cPackages;
SecPkgInfoW* pPackageInfo =
(SecPkgInfoW*)sspi_ContextBufferAlloc(EnumerateSecurityPackagesIndex, size);
if (!pPackageInfo)
return SEC_E_INSUFFICIENT_MEMORY;
@ -1101,12 +1099,10 @@ static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesW(ULONG* pcPacka
static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesA(ULONG* pcPackages,
PSecPkgInfoA* ppPackageInfo)
{
size_t size = 0;
UINT32 cPackages = 0;
SecPkgInfoA* pPackageInfo = NULL;
cPackages = sizeof(SecPkgInfoA_LIST) / sizeof(*(SecPkgInfoA_LIST));
size = sizeof(SecPkgInfoA) * cPackages;
pPackageInfo = (SecPkgInfoA*)sspi_ContextBufferAlloc(EnumerateSecurityPackagesIndex, size);
size_t cPackages = ARRAYSIZE(SecPkgInfoA_LIST);
size_t size = sizeof(SecPkgInfoA) * cPackages;
SecPkgInfoA* pPackageInfo =
(SecPkgInfoA*)sspi_ContextBufferAlloc(EnumerateSecurityPackagesIndex, size);
if (!pPackageInfo)
return SEC_E_INSUFFICIENT_MEMORY;
@ -1134,9 +1130,8 @@ static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesA(ULONG* pcPacka
static void FreeContextBuffer_EnumerateSecurityPackages(void* contextBuffer)
{
UINT32 cPackages = 0;
SecPkgInfoA* pPackageInfo = (SecPkgInfoA*)contextBuffer;
cPackages = sizeof(SecPkgInfoA_LIST) / sizeof(*(SecPkgInfoA_LIST));
size_t cPackages = ARRAYSIZE(SecPkgInfoA_LIST);
if (!pPackageInfo)
return;
@ -1163,16 +1158,14 @@ SecurityFunctionTableA* SEC_ENTRY winpr_InitSecurityInterfaceA(void)
static SECURITY_STATUS SEC_ENTRY winpr_QuerySecurityPackageInfoW(SEC_WCHAR* pszPackageName,
PSecPkgInfoW* ppPackageInfo)
{
size_t size = 0;
SecPkgInfoW* pPackageInfo = NULL;
size_t cPackages = sizeof(SecPkgInfoW_LIST) / sizeof(*(SecPkgInfoW_LIST));
size_t cPackages = ARRAYSIZE(SecPkgInfoW_LIST);
for (size_t index = 0; index < cPackages; index++)
{
if (_wcscmp(pszPackageName, SecPkgInfoW_LIST[index]->Name) == 0)
{
size = sizeof(SecPkgInfoW);
pPackageInfo =
size_t size = sizeof(SecPkgInfoW);
SecPkgInfoW* pPackageInfo =
(SecPkgInfoW*)sspi_ContextBufferAlloc(QuerySecurityPackageInfoIndex, size);
if (!pPackageInfo)
@ -1196,16 +1189,14 @@ static SECURITY_STATUS SEC_ENTRY winpr_QuerySecurityPackageInfoW(SEC_WCHAR* pszP
static SECURITY_STATUS SEC_ENTRY winpr_QuerySecurityPackageInfoA(SEC_CHAR* pszPackageName,
PSecPkgInfoA* ppPackageInfo)
{
size_t size = 0;
SecPkgInfoA* pPackageInfo = NULL;
size_t cPackages = sizeof(SecPkgInfoA_LIST) / sizeof(*(SecPkgInfoA_LIST));
size_t cPackages = ARRAYSIZE(SecPkgInfoA_LIST);
for (size_t index = 0; index < cPackages; index++)
{
if (strcmp(pszPackageName, SecPkgInfoA_LIST[index]->Name) == 0)
{
size = sizeof(SecPkgInfoA);
pPackageInfo =
size_t size = sizeof(SecPkgInfoA);
SecPkgInfoA* pPackageInfo =
(SecPkgInfoA*)sspi_ContextBufferAlloc(QuerySecurityPackageInfoIndex, size);
if (!pPackageInfo)