From 5b923b967de52d63ab7537f2e9a252459fdb0cf4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 8 Feb 2021 09:32:19 +0100 Subject: [PATCH] (7zip) Silence warnings on OSX/Xcode/Clang --- deps/7zip/7zDec.c | 12 ++--- deps/7zip/7zIn.c | 104 ++++++++++++++++++++++--------------------- deps/7zip/7zStream.c | 14 +++--- deps/7zip/Lzma2Dec.c | 12 ++--- deps/7zip/LzmaDec.c | 6 +-- deps/7zip/LzmaEnc.c | 6 +-- 6 files changed, 78 insertions(+), 76 deletions(-) diff --git a/deps/7zip/7zDec.c b/deps/7zip/7zDec.c index 71943924a9..c556548b6e 100644 --- a/deps/7zip/7zDec.c +++ b/deps/7zip/7zDec.c @@ -27,7 +27,7 @@ static SRes SzDecodeLzma(CSzCoderInfo *coder, uint64_t inSize, ILookInStream *inStream, uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) { - int result; + SRes result; CLzmaDec state; SRes res = SZ_OK; @@ -91,7 +91,7 @@ static SRes SzDecodeLzma2(CSzCoderInfo *coder, uint64_t inSize, ILookInStream *inStream, uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) { - int result; + SRes result; CLzma2Dec state; SRes res = SZ_OK; @@ -152,7 +152,7 @@ static SRes SzDecodeCopy(uint64_t inSize, { while (inSize > 0) { - int result; + SRes result; void *inBuf = NULL; size_t curSize = (1 << 18); if (curSize > inSize) @@ -284,7 +284,7 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, size_t tempSizes[3] = { 0, 0, 0}; size_t tempSize3 = 0; uint8_t *tempBuf3 = 0; - int result = check_supported_folder(folder); + SRes result = check_supported_folder(folder); if (result != 0) return result; @@ -295,7 +295,7 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, if (is_main_method((uint32_t)coder->MethodID)) { - int result; + SRes result; uint64_t offset = 0; uint64_t inSize = 0; uint32_t si = 0; @@ -369,7 +369,7 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, else if (coder->MethodID == k_BCJ2) { SRes res; - int result; + SRes result; uint64_t offset = get_sum(packSizes, 1); uint64_t s3Size = packSizes[1]; diff --git a/deps/7zip/7zIn.c b/deps/7zip/7zIn.c index 0e4ec7e4c9..0a8e27f56e 100644 --- a/deps/7zip/7zIn.c +++ b/deps/7zip/7zIn.c @@ -318,7 +318,7 @@ static SRes SzReaduint8_ts(CSzData *sd, uint8_t *data, size_t size) size_t i; for (i = 0; i < size; i++) { - int result = SzReaduint8_t(sd, data + i); + SRes result = SzReaduint8_t(sd, data + i); if (result != 0) return result; } @@ -331,8 +331,8 @@ static SRes SzReaduint32_t(CSzData *sd, uint32_t *value) *value = 0; for (i = 0; i < 4; i++) { - uint8_t b = 0; - int result = SzReaduint8_t(sd, &b); + uint8_t b = 0; + SRes result = SzReaduint8_t(sd, &b); if (result != 0) return result; *value |= ((uint32_t)(b) << (8 * i)); @@ -345,7 +345,7 @@ static SRes SzReadNumber(CSzData *sd, uint64_t *value) int i; uint8_t firstuint8_t = 0; uint8_t mask = 0x80; - int result = SzReaduint8_t(sd, &firstuint8_t); + SRes result = SzReaduint8_t(sd, &firstuint8_t); if (result != 0) return result; @@ -354,7 +354,7 @@ static SRes SzReadNumber(CSzData *sd, uint64_t *value) for (i = 0; i < 8; i++) { - int result; + SRes result; uint8_t b = 0; if ((firstuint8_t & mask) == 0) { @@ -375,7 +375,7 @@ static SRes SzReadNumber(CSzData *sd, uint64_t *value) static SRes SzReadNumber32(CSzData *sd, uint32_t *value) { uint64_t value64; - int result = SzReadNumber(sd, &value64); + SRes result = SzReadNumber(sd, &value64); if (result != 0) return result; if (value64 >= 0x80000000) @@ -403,7 +403,7 @@ static SRes SzSkeepDataSize(CSzData *sd, uint64_t size) static SRes SzSkeepData(CSzData *sd) { uint64_t size; - int result = SzReadNumber(sd, &size); + SRes result = SzReadNumber(sd, &size); if (result != 0) return result; return SzSkeepDataSize(sd, size); @@ -414,7 +414,7 @@ static SRes SzReadArchiveProperties(CSzData *sd) for (;;) { uint64_t type; - int result = SzReadID(sd, &type); + SRes result = SzReadID(sd, &type); if (result != 0) return result; if (type == k7zIdEnd) @@ -429,7 +429,7 @@ static SRes SzWaitAttribute(CSzData *sd, uint64_t attribute) for (;;) { uint64_t type; - int result = SzReadID(sd, &type); + SRes result = SzReadID(sd, &type); if (result != 0) return result; if (type == attribute) @@ -453,7 +453,7 @@ static SRes SzReadBoolVector( { if (mask == 0) { - int result = SzReaduint8_t(sd, &b); + SRes result = SzReaduint8_t(sd, &b); if (result != 0) return result; mask = 0x80; @@ -468,7 +468,7 @@ static SRes SzReadBoolVector2(CSzData *sd, size_t numItems, uint8_t **v, ISzAllo { size_t i; uint8_t allAreDefined = 0; - int result = SzReaduint8_t(sd, &allAreDefined); + SRes result = SzReaduint8_t(sd, &allAreDefined); if (result != 0) return result; @@ -488,7 +488,7 @@ static SRes SzReadHashDigests( ISzAlloc *alloc) { size_t i; - int result = SzReadBoolVector2(sd, numItems, digestsDefined, alloc); + SRes result = SzReadBoolVector2(sd, numItems, digestsDefined, alloc); if (result != 0) return result; @@ -499,7 +499,7 @@ static SRes SzReadHashDigests( { if ((*digestsDefined)[i]) { - int result = SzReaduint32_t(sd, (*digests) + i); + SRes result = SzReaduint32_t(sd, (*digests) + i); if (result != 0) return result; } @@ -517,7 +517,7 @@ static SRes SzReadPackInfo( ISzAlloc *alloc) { uint32_t i; - int result = SzReadNumber(sd, dataOffset); + SRes result = SzReadNumber(sd, dataOffset); if (result != 0) return result; @@ -572,7 +572,7 @@ static SRes SzReadPackInfo( static SRes SzReadSwitch(CSzData *sd) { uint8_t external = 0; - int result = SzReaduint8_t(sd, &external); + SRes result = SzReaduint8_t(sd, &external); if (result != 0) return result; if (external != 0) @@ -588,7 +588,7 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) uint32_t numInStreams = 0; uint32_t numOutStreams = 0; uint32_t numCoders = 0; - int result = SzReadNumber32(sd, &numCoders); + SRes result = SzReadNumber32(sd, &numCoders); if (result != 0) return result; @@ -607,7 +607,7 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) uint8_t longID[15]; uint8_t mainuint8_t = 0; CSzCoderInfo *coder = folder->Coders + i; - int result = SzReaduint8_t(sd, &mainuint8_t); + SRes result = SzReaduint8_t(sd, &mainuint8_t); if (result != 0) return result; @@ -627,7 +627,7 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) if ((mainuint8_t & 0x10) != 0) { - int result = SzReadNumber32(sd, &coder->NumInStreams); + SRes result = SzReadNumber32(sd, &coder->NumInStreams); if (result != 0) return result; @@ -649,7 +649,7 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) if ((mainuint8_t & 0x20) != 0) { uint64_t propertiesSize = 0; - int result = SzReadNumber(sd, &propertiesSize); + SRes result = SzReadNumber(sd, &propertiesSize); if (result != 0) return result; @@ -670,7 +670,7 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) if ((mainuint8_t & 0x10) != 0) { uint32_t n; - int result = SzReadNumber32(sd, &n); + SRes result = SzReadNumber32(sd, &n); if (result != 0) return result; result = SzReadNumber32(sd, &n); @@ -680,7 +680,7 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) if ((mainuint8_t & 0x20) != 0) { uint64_t propertiesSize = 0; - int result = SzReadNumber(sd, &propertiesSize); + SRes result = SzReadNumber(sd, &propertiesSize); if (result != 0) return result; result = SzSkeepDataSize(sd, propertiesSize); @@ -701,7 +701,7 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) for (i = 0; i < numBindPairs; i++) { CSzBindPair *bp = folder->BindPairs + i; - int result = SzReadNumber32(sd, &bp->InIndex); + SRes result = SzReadNumber32(sd, &bp->InIndex); if (result != 0) return result; @@ -728,7 +728,7 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) else for (i = 0; i < numPackStreams; i++) { - int result = SzReadNumber32(sd, folder->PackStreams + i); + SRes result = SzReadNumber32(sd, folder->PackStreams + i); if (result != 0) return result; } @@ -743,7 +743,7 @@ static SRes SzReadUnpackInfo( ISzAlloc *allocTemp) { uint32_t i; - int result = SzWaitAttribute(sd, k7zIdFolder); + SRes result = SzWaitAttribute(sd, k7zIdFolder); if (result != 0) return result; @@ -788,7 +788,7 @@ static SRes SzReadUnpackInfo( for (j = 0; j < numOutStreams; j++) { - int result = SzReadNumber(sd, folder->UnpackSizes + j); + SRes result = SzReadNumber(sd, folder->UnpackSizes + j); if (result != 0) return result; } @@ -797,7 +797,7 @@ static SRes SzReadUnpackInfo( for (;;) { uint64_t type; - int result = SzReadID(sd, &type); + SRes result = SzReadID(sd, &type); if (result != 0) return result; if (type == k7zIdEnd) @@ -840,7 +840,7 @@ static SRes SzReadSubStreamsInfo( uint32_t **digests, ISzAlloc *allocTemp) { - int result; + SRes result; uint32_t i; uint64_t type = 0; uint32_t si = 0; @@ -852,7 +852,7 @@ static SRes SzReadSubStreamsInfo( for (;;) { - int result = SzReadID(sd, &type); + SRes result = SzReadID(sd, &type); if (result != 0) return result; if (type == k7zIdNumUnpackStream) @@ -861,7 +861,7 @@ static SRes SzReadSubStreamsInfo( for (i = 0; i < numFolders; i++) { uint32_t numStreams = 0; - int result = SzReadNumber32(sd, &numStreams); + SRes result = SzReadNumber32(sd, &numStreams); if (result != 0) return result; @@ -913,7 +913,7 @@ static SRes SzReadSubStreamsInfo( for (j = 1; j < numSubstreams; j++) { uint64_t size; - int result = SzReadNumber(sd, &size); + SRes result = SzReadNumber(sd, &size); if (result != 0) return result; @@ -922,6 +922,7 @@ static SRes SzReadSubStreamsInfo( } (*unpackSizes)[si++] = SzFolder_GetUnpackSize(folders + i) - sum; } + if (type == k7zIdSize) { result = SzReadID(sd, &type); @@ -1011,7 +1012,7 @@ static SRes SzReadStreamsInfo( for (;;) { uint64_t type; - int result = SzReadID(sd, &type); + SRes result = SzReadID(sd, &type); if (result != 0) return result; @@ -1023,7 +1024,7 @@ static SRes SzReadStreamsInfo( return SZ_OK; case k7zIdPackInfo: { - int result = SzReadPackInfo(sd, dataOffset, &p->NumPackStreams, + SRes result = SzReadPackInfo(sd, dataOffset, &p->NumPackStreams, &p->PackSizes, &p->PackCRCsDefined, &p->PackCRCs, alloc); if (result != 0) return result; @@ -1032,14 +1033,14 @@ static SRes SzReadStreamsInfo( } case k7zIdUnpackInfo: { - int result = SzReadUnpackInfo(sd, &p->NumFolders, &p->Folders, alloc, allocTemp); + SRes result = SzReadUnpackInfo(sd, &p->NumFolders, &p->Folders, alloc, allocTemp); if (result != 0) return result; break; } case k7zIdSubStreamsInfo: { - int result = SzReadSubStreamsInfo(sd, p->NumFolders, p->Folders, + SRes result = SzReadSubStreamsInfo(sd, p->NumFolders, p->Folders, numUnpackStreams, unpackSizes, digestsDefined, digests, allocTemp); if (result != 0) return result; @@ -1107,7 +1108,7 @@ static SRes SzReadHeader2( uint32_t numFiles = 0; CSzFileItem *files = 0; uint32_t numEmptyStreams = 0; - int result = SzReadID(sd, &type); + SRes result = SzReadID(sd, &type); if (result != 0) return result; @@ -1159,7 +1160,7 @@ static SRes SzReadHeader2( for (;;) { uint64_t size; - int result = SzReadID(sd, &type); + SRes result = SzReadID(sd, &type); if (result != 0) return result; @@ -1175,7 +1176,7 @@ static SRes SzReadHeader2( if ((uint64_t)(int)type != type) { - int result = SzSkeepDataSize(sd, size); + SRes result = SzSkeepDataSize(sd, size); if (result != 0) return result; } @@ -1184,7 +1185,7 @@ static SRes SzReadHeader2( { case k7zIdName: { - int result = SzReadSwitch(sd); + SRes result = SzReadSwitch(sd); size_t namesSize = (size_t)size - 1; if (result != 0) return result; @@ -1204,7 +1205,7 @@ static SRes SzReadHeader2( } case k7zIdEmptyStream: { - int result = SzReadBoolVector(sd, numFiles, emptyStreamVector, allocTemp); + SRes result = SzReadBoolVector(sd, numFiles, emptyStreamVector, allocTemp); if (result != 0) return result; numEmptyStreams = 0; @@ -1215,17 +1216,17 @@ static SRes SzReadHeader2( } case k7zIdEmptyFile: { - int result = SzReadBoolVector(sd, numEmptyStreams, emptyFileVector, allocTemp); + SRes result = SzReadBoolVector(sd, numEmptyStreams, emptyFileVector, allocTemp); if (result != 0) return result; break; } case k7zIdWinAttributes: { - int result = SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp); + SRes result = SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp); if (result != 0) return result; - result = SzReadSwitch(sd); + result = SzReadSwitch(sd); if (result != 0) return result; @@ -1248,11 +1249,11 @@ static SRes SzReadHeader2( } case k7zIdMTime: { - int result = SzReadBoolVector2(sd, + SRes result = SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp); if (result != 0) return result; - result = SzReadSwitch(sd); + result = SzReadSwitch(sd); if (result != 0) return result; @@ -1364,7 +1365,7 @@ static SRes SzReadAndDecodePackedStreams2( uint64_t dataStartPos = 0; uint64_t unpackSize = 0; uint32_t numUnpackStreams = 0; - int result = SzReadStreamsInfo(sd, &dataStartPos, p, + SRes result = SzReadStreamsInfo(sd, &dataStartPos, p, &numUnpackStreams, unpackSizes, digestsDefined, digests, allocTemp, allocTemp); @@ -1435,13 +1436,13 @@ static SRes SzArEx_Open2( uint64_t nextHeaderOffset, nextHeaderSize; size_t nextHeaderSizeT; uint32_t nextHeaderCRC; - int64_t startArcPos = 0; - int result = inStream->Seek(inStream, &startArcPos, SZ_SEEK_CUR); + int64_t startArcPos = 0; + SRes result = inStream->Seek(inStream, &startArcPos, SZ_SEEK_CUR); if (result != 0) return result; - result = LookInStream_Read2(inStream, header, + result = LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE); @@ -1472,11 +1473,12 @@ static SRes SzArEx_Open2( return SZ_ERROR_NO_ARCHIVE; { - int64_t pos = 0; - int result = inStream->Seek(inStream, &pos, SZ_SEEK_END); + int64_t pos = 0; + SRes result = inStream->Seek(inStream, &pos, SZ_SEEK_END); if (result != 0) return result; + if ((uint64_t)pos < startArcPos + nextHeaderOffset || (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset || (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) @@ -1571,7 +1573,7 @@ SRes SzArEx_Extract( if (*outBuffer == 0 || *blockIndex != folderIndex) { - int result; + SRes result; CSzFolder *folder = p->db.Folders + folderIndex; uint64_t unpackSizeSpec = SzFolder_GetUnpackSize(folder); size_t unpackSize = (size_t)unpackSizeSpec; diff --git a/deps/7zip/7zStream.c b/deps/7zip/7zStream.c index 1aac4d777b..2d41b889c3 100644 --- a/deps/7zip/7zStream.c +++ b/deps/7zip/7zStream.c @@ -9,8 +9,8 @@ SRes SeqInStream_Readuint8_t(ISeqInStream *stream, uint8_t *buf) { - size_t processed = 1; - int result = stream->Read(stream, buf, &processed); + size_t processed = 1; + SRes result = stream->Read(stream, buf, &processed); if (result != 0) return result; if (processed != 1) @@ -22,8 +22,8 @@ SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorT { while (size != 0) { - size_t processed = size; - int result = stream->Read(stream, buf, &processed); + size_t processed = size; + SRes result = stream->Read(stream, buf, &processed); if (result != 0) return result; if (processed == 0) @@ -48,7 +48,7 @@ SRes LookInStream_SeekTo(ILookInStream *stream, uint64_t offset) SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size) { - int result; + SRes result; const void *lookBuf; if (*size == 0) return SZ_OK; @@ -64,8 +64,8 @@ SRes LookInStream_Read2(ILookInStream *stream, { while (size != 0) { - size_t processed = size; - int result = stream->Read(stream, buf, &processed); + size_t processed = size; + SRes result = stream->Read(stream, buf, &processed); if (result != 0) return result; if (processed == 0) diff --git a/deps/7zip/Lzma2Dec.c b/deps/7zip/Lzma2Dec.c index 0a4ed84907..836604b37d 100644 --- a/deps/7zip/Lzma2Dec.c +++ b/deps/7zip/Lzma2Dec.c @@ -66,7 +66,7 @@ static SRes Lzma2Dec_GetOldProps(uint8_t prop, uint8_t *props) SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc) { uint8_t props[LZMA_PROPS_SIZE]; - int result = Lzma2Dec_GetOldProps(prop, props); + SRes result = Lzma2Dec_GetOldProps(prop, props); if (result != 0) return result; return LzmaDec_AllocateProbs(&p->decoder, props, LZMA_PROPS_SIZE, alloc); @@ -75,7 +75,7 @@ SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc) SRes Lzma2Dec_Allocate(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc) { uint8_t props[LZMA_PROPS_SIZE]; - int result = Lzma2Dec_GetOldProps(prop, props); + SRes result = Lzma2Dec_GetOldProps(prop, props); if (result != 0) return result; return LzmaDec_Allocate(&p->decoder, props, LZMA_PROPS_SIZE, alloc); @@ -327,16 +327,16 @@ SRes Lzma2Decode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *src uint8_t prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc) { SRes res; - int result; + SRes result; CLzma2Dec decoder; size_t outSize = *destLen, inSize = *srcLen; uint8_t props[LZMA_PROPS_SIZE]; Lzma2Dec_Construct(&decoder); - *destLen = *srcLen = 0; - *status = LZMA_STATUS_NOT_SPECIFIED; - decoder.decoder.dic = dest; + *destLen = *srcLen = 0; + *status = LZMA_STATUS_NOT_SPECIFIED; + decoder.decoder.dic = dest; decoder.decoder.dicBufSize = outSize; result = Lzma2Dec_GetOldProps(prop, props); diff --git a/deps/7zip/LzmaDec.c b/deps/7zip/LzmaDec.c index 909f6ac29d..def938baf6 100644 --- a/deps/7zip/LzmaDec.c +++ b/deps/7zip/LzmaDec.c @@ -993,7 +993,7 @@ SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc) { CLzmaProps propNew; - int result = LzmaProps_Decode(&propNew, props, propsSize); + SRes result = LzmaProps_Decode(&propNew, props, propsSize); if (result != 0) return result; result = LzmaDec_AllocateProbs2(p, &propNew, alloc); @@ -1008,12 +1008,12 @@ SRes LzmaDec_Allocate(CLzmaDec *p, const uint8_t *props, { CLzmaProps propNew; size_t dicBufSize; - int result = LzmaProps_Decode(&propNew, props, propsSize); + SRes result = LzmaProps_Decode(&propNew, props, propsSize); if (result != 0) return result; - result = LzmaDec_AllocateProbs2(p, &propNew, alloc); + result = LzmaDec_AllocateProbs2(p, &propNew, alloc); if (result != 0) return result; diff --git a/deps/7zip/LzmaEnc.c b/deps/7zip/LzmaEnc.c index c05244a8a2..16ca19bac2 100644 --- a/deps/7zip/LzmaEnc.c +++ b/deps/7zip/LzmaEnc.c @@ -1739,7 +1739,7 @@ void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig) static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, bool useLimits, uint32_t maxPackSize, uint32_t maxUnpackSize) { - int result; + SRes result; uint32_t nowPos32, startPos32; if (p->needInit) { @@ -2034,7 +2034,7 @@ static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, uint32_t keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) { uint32_t i; - int result; + SRes result; for (i = 0; i < (uint32_t)kDicLogSizeMaxCompress; i++) if (p->dictSize <= ((uint32_t)1 << i)) break; @@ -2214,7 +2214,7 @@ SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqInStream *inStream, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) { - int result = LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig); + SRes result = LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig); if (result != 0) return result; return LzmaEnc_Encode2((CLzmaEnc *)pp, progress);