Fix alignment warnings with pointer casting
This commit is contained in:
@@ -103,18 +103,17 @@ size_t HUF_readDTableX2_wksp(HUF_DTable* DTable, const void* src, size_t srcSize
|
|||||||
|
|
||||||
U32* rankVal;
|
U32* rankVal;
|
||||||
BYTE* huffWeight;
|
BYTE* huffWeight;
|
||||||
size_t spaceUsed = 0;
|
size_t spaceUsed32 = 0;
|
||||||
|
|
||||||
rankVal = (U32 *)((BYTE *)workSpace + spaceUsed);
|
rankVal = (U32 *)workSpace + spaceUsed32;
|
||||||
spaceUsed += sizeof(U32) * (HUF_TABLELOG_ABSOLUTEMAX + 1);
|
spaceUsed32 += HUF_TABLELOG_ABSOLUTEMAX + 1;
|
||||||
huffWeight = (BYTE *)workSpace + spaceUsed;
|
huffWeight = (BYTE *)((U32 *)workSpace + spaceUsed32);
|
||||||
spaceUsed += HUF_SYMBOLVALUE_MAX + 1;
|
spaceUsed32 += ALIGN(HUF_SYMBOLVALUE_MAX + 1, sizeof(U32)) >> 2;
|
||||||
spaceUsed = ALIGN(spaceUsed, sizeof(U32));
|
|
||||||
|
|
||||||
if (spaceUsed > wkspSize)
|
if ((spaceUsed32 >> 2) > wkspSize)
|
||||||
return ERROR(tableLog_tooLarge);
|
return ERROR(tableLog_tooLarge);
|
||||||
workSpace = (BYTE *)workSpace + spaceUsed;
|
workSpace = (U32 *)workSpace + spaceUsed32;
|
||||||
wkspSize -= spaceUsed;
|
wkspSize -= (spaceUsed32 << 2);
|
||||||
|
|
||||||
HUF_STATIC_ASSERT(sizeof(DTableDesc) == sizeof(HUF_DTable));
|
HUF_STATIC_ASSERT(sizeof(DTableDesc) == sizeof(HUF_DTable));
|
||||||
/* memset(huffWeight, 0, sizeof(huffWeight)); */ /* is not necessary, even though some analyzer complain ... */
|
/* memset(huffWeight, 0, sizeof(huffWeight)); */ /* is not necessary, even though some analyzer complain ... */
|
||||||
@@ -512,24 +511,23 @@ size_t HUF_readDTableX4_wksp(HUF_DTable* DTable, const void* src,
|
|||||||
U32* rankStart0;
|
U32* rankStart0;
|
||||||
sortedSymbol_t* sortedSymbol;
|
sortedSymbol_t* sortedSymbol;
|
||||||
BYTE* weightList;
|
BYTE* weightList;
|
||||||
size_t spaceUsed = 0;
|
size_t spaceUsed32 = 0;
|
||||||
|
|
||||||
rankVal = (rankValCol_t *)((BYTE *)workSpace + spaceUsed);
|
rankVal = (rankValCol_t *)((U32 *)workSpace + spaceUsed32);
|
||||||
spaceUsed += sizeof(rankValCol_t) * HUF_TABLELOG_MAX;
|
spaceUsed32 += (sizeof(rankValCol_t) * HUF_TABLELOG_MAX) >> 2;
|
||||||
rankStats = (U32 *)((BYTE *)workSpace + spaceUsed);
|
rankStats = (U32 *)workSpace + spaceUsed32;
|
||||||
spaceUsed += sizeof(U32) * (HUF_TABLELOG_MAX + 1);
|
spaceUsed32 += HUF_TABLELOG_MAX + 1;
|
||||||
rankStart0 = (U32 *)((BYTE *)workSpace + spaceUsed);
|
rankStart0 = (U32 *)workSpace + spaceUsed32;
|
||||||
spaceUsed += sizeof(U32) * (HUF_TABLELOG_MAX + 2);
|
spaceUsed32 += HUF_TABLELOG_MAX + 2;
|
||||||
sortedSymbol = (sortedSymbol_t *)((BYTE *)workSpace + spaceUsed);
|
sortedSymbol = (sortedSymbol_t *)((U32 *)workSpace + spaceUsed32);
|
||||||
spaceUsed += sizeof(sortedSymbol_t) * (HUF_SYMBOLVALUE_MAX + 1);
|
spaceUsed32 += ALIGN(sizeof(sortedSymbol_t) * (HUF_SYMBOLVALUE_MAX + 1), sizeof(U32)) >> 2;
|
||||||
weightList = (BYTE *)workSpace + spaceUsed;
|
weightList = (BYTE *)((U32 *)workSpace + spaceUsed32);
|
||||||
spaceUsed += HUF_SYMBOLVALUE_MAX + 1;
|
spaceUsed32 += ALIGN(HUF_SYMBOLVALUE_MAX + 1, sizeof(U32)) >> 2;
|
||||||
spaceUsed = ALIGN(spaceUsed, sizeof(U32));
|
|
||||||
|
|
||||||
if (spaceUsed > wkspSize)
|
if ((spaceUsed32 >> 2) > wkspSize)
|
||||||
return ERROR(tableLog_tooLarge);
|
return ERROR(tableLog_tooLarge);
|
||||||
workSpace = (BYTE *)workSpace + spaceUsed;
|
workSpace = (U32 *)workSpace + spaceUsed32;
|
||||||
wkspSize -= spaceUsed;
|
wkspSize -= (spaceUsed32 << 2);
|
||||||
|
|
||||||
rankStart = rankStart0 + 1;
|
rankStart = rankStart0 + 1;
|
||||||
memset(rankStats, 0, sizeof(U32) * (2 * HUF_TABLELOG_MAX + 2 + 1));
|
memset(rankStats, 0, sizeof(U32) * (2 * HUF_TABLELOG_MAX + 2 + 1));
|
||||||
|
|||||||
Reference in New Issue
Block a user