Skip to content

Commit 26b2bdb

Browse files
committed
all: Fix some compiler warnings
1 parent 4dc8898 commit 26b2bdb

File tree

2 files changed

+37
-39
lines changed

2 files changed

+37
-39
lines changed

XUnzip.cpp

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ typedef unsigned short WORD;
8989
#define _tcsicmp stricmp
9090
#define _tcsncpy strncpy
9191
#define _tcsstr strstr
92-
#define _sntprintf _snprintf
92+
#define _sntprintf snprintf
9393
#define INVALID_HANDLE_VALUE nullptr
9494
#define INVALID_SET_FILE_POINTER 0xFFFFFFFFUL
9595
#ifndef _T
@@ -119,7 +119,6 @@ typedef unsigned short WORD;
119119
enum ZipMode { ZIP_HANDLE = 1, ZIP_FILENAME = 2, ZIP_MEMORY = 3 };
120120

121121
#define zmalloc(len) malloc(len)
122-
123122
#define zfree(p) free(p)
124123

125124
namespace {
@@ -1635,7 +1634,7 @@ int huft_build(uInt *b, // code lengths in bits (all assumed <= BMAX)
16351634
#define C2 C0 C0 C0 C0
16361635
#define C4 C2 C2 C2 C2
16371636
C4;
1638-
p; // clear c[]--assume BMAX+1 is 16
1637+
// clear c[]--assume BMAX+1 is 16
16391638
p = b;
16401639
i = n;
16411640
do {
@@ -2398,7 +2397,6 @@ int inflate(z_streamp z, int f) {
23982397
z->state->mode = IM_DICT1;
23992398
case IM_DICT1:
24002399
IM_NEEDBYTE;
2401-
r;
24022400
z->state->sub.check.need += (uLong)IM_NEXTBYTE;
24032401
z->adler = z->state->sub.check.need;
24042402
z->state->mode = IM_DICT0;
@@ -2850,7 +2848,7 @@ uLong unzlocal_SearchCentralDir(LUFILE *fin) {
28502848
long uMaxBack{0xFFFF}; // maximum size of global comment
28512849
if (uMaxBack > uSizeFile) uMaxBack = uSizeFile;
28522850

2853-
constexpr size_t bufSize{BUFREADCOMMENT + 4};
2851+
constexpr long bufSize{BUFREADCOMMENT + 4};
28542852
auto buf = std::make_unique<unsigned char[]>(bufSize);
28552853
if (!buf) return 0xFFFFFFFF;
28562854

@@ -3043,11 +3041,13 @@ int unzlocal_GetCurrentFileInfoInternal(
30433041
err = UNZ_ERRNO;
30443042

30453043
// we check the magic
3046-
if (err == UNZ_OK)
3047-
if (unzlocal_getLong(s->file, &uMagic) != UNZ_OK)
3044+
if (err == UNZ_OK) {
3045+
if (unzlocal_getLong(s->file, &uMagic) != UNZ_OK) {
30483046
err = UNZ_ERRNO;
3049-
else if (uMagic != 0x02014b50)
3047+
} else if (uMagic != 0x02014b50) {
30503048
err = UNZ_BADZIPFILE;
3049+
}
3050+
}
30513051

30523052
if (unzlocal_getShort(s->file, &file_info.version) != UNZ_OK) err = UNZ_ERRNO;
30533053

@@ -3115,11 +3115,13 @@ int unzlocal_GetCurrentFileInfoInternal(
31153115
else
31163116
uSizeRead = extraFieldBufferSize;
31173117

3118-
if (lSeek != 0)
3119-
if (lufseek(s->file, lSeek, SEEK_CUR) == 0)
3118+
if (lSeek != 0) {
3119+
if (lufseek(s->file, lSeek, SEEK_CUR) == 0) {
31203120
lSeek = 0;
3121-
else
3121+
} else {
31223122
err = UNZ_ERRNO;
3123+
}
3124+
}
31233125

31243126
if ((file_info.size_file_extra > 0) && (extraFieldBufferSize > 0))
31253127
if (lufread(extraField, (uInt)uSizeRead, 1, s->file) != 1)
@@ -3138,10 +3140,9 @@ int unzlocal_GetCurrentFileInfoInternal(
31383140
uSizeRead = commentBufferSize;
31393141

31403142
if (lSeek != 0)
3141-
if (lufseek(s->file, lSeek, SEEK_CUR) == 0) {
3142-
} // unused lSeek=0;
3143-
else
3143+
if (lufseek(s->file, lSeek, SEEK_CUR) != 0) {
31443144
err = UNZ_ERRNO;
3145+
}
31453146

31463147
if ((file_info.size_file_comment > 0) && (commentBufferSize > 0))
31473148
if (lufread(szComment, (uInt)uSizeRead, 1, s->file) != 1) err = UNZ_ERRNO;
@@ -3439,7 +3440,7 @@ int unzReadCurrentFile(unzFile file, voidp buf, unsigned len,
34393440

34403441
file_in_zip_read_info_s *pfile_in_zip_read_info = s->pfile_in_zip_read;
34413442
if (pfile_in_zip_read_info == nullptr) return UNZ_PARAMERROR;
3442-
if ((pfile_in_zip_read_info->read_buffer == nullptr)) {
3443+
if (pfile_in_zip_read_info->read_buffer == nullptr) {
34433444
return UNZ_END_OF_LIST_OF_FILE;
34443445
}
34453446

@@ -3910,7 +3911,7 @@ ZRESULT TUnzip::Get(int index, ZIPENTRY *ze) {
39103911
bool readonly = (a & 0x00800000) == 0;
39113912
// bool readable= (a&0x01000000)!=0; // unused
39123913
// bool executable=(a&0x00400000)!=0; // unused
3913-
bool hidden = false, system = false, archive = true;
3914+
[[maybe_unused]] bool hidden = false, system = false, archive = true;
39143915
// but in normal hostmodes these are overridden by the lower half...
39153916
int host = ufi.version >> 8;
39163917
if (host == 0 || host == 7 || host == 11 || host == 14) {
@@ -3920,11 +3921,6 @@ ZRESULT TUnzip::Get(int index, ZIPENTRY *ze) {
39203921
isdir = (a & 0x00000010) != 0;
39213922
archive = (a & 0x00000020) != 0;
39223923
}
3923-
readonly;
3924-
hidden;
3925-
system;
3926-
isdir;
3927-
archive;
39283924
ze->attr = 0;
39293925

39303926
#ifdef ZIP_STD
@@ -4087,16 +4083,13 @@ ZRESULT EnsureDirectory(const TCHAR *rootdir, const TCHAR *dir) {
40874083
c++;
40884084
}
40894085

4090-
const TCHAR *name{lastslash};
40914086
if (lastslash != dir) {
40924087
TCHAR tmp[MAX_PATH];
40934088
memcpy(tmp, dir, sizeof(TCHAR) * (lastslash - dir));
40944089
tmp[lastslash - dir] = 0;
40954090

40964091
ZRESULT rc = EnsureDirectory(rootdir, tmp);
40974092
if (rc != ZR_OK) return rc;
4098-
4099-
name++;
41004093
}
41014094

41024095
TCHAR cd[MAX_PATH];
@@ -4488,6 +4481,9 @@ size_t FormatZipMessageU(ZRESULT code, TCHAR *buf, size_t len) {
44884481
case ZR_FLATE:
44894482
msg = _T("Zip-bug: an internal error during flation");
44904483
break;
4484+
default:
4485+
// Use default one.
4486+
break;
44914487
}
44924488

44934489
const size_t mlen{_tcslen(msg)};

XZip.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -808,20 +808,20 @@ ZRESULT GetFileInfo(HANDLE hf, ulg *attr, long *size, iztimes *times,
808808
#endif
809809
// ----------------------------------------------------------------------
810810

811-
void Assert(TState &state, bool cond, const char *msg) {
811+
[[maybe_unused]] void Assert(TState &state, bool cond, const char *msg) {
812812
if (cond) return;
813813
state.err = msg;
814814
}
815-
void Trace(const char *x, ...) {
815+
[[maybe_unused]] void Trace(const char *x, ...) {
816816
va_list paramList;
817817
va_start(paramList, x);
818-
paramList;
818+
// paramList;
819819
va_end(paramList);
820820
}
821-
void Tracec(bool, const char *x, ...) {
821+
[[maybe_unused]] void Tracec(bool, const char *x, ...) {
822822
va_list paramList;
823823
va_start(paramList, x);
824-
paramList;
824+
// paramList;
825825
va_end(paramList);
826826
}
827827

@@ -2200,8 +2200,7 @@ ulg deflate(TState &state) {
22002200
}
22012201

22022202
// Write a local header described by *z to file *f. Return a ZE_ error code.
2203-
int putlocal(struct zlist *z, WRITEFUNC wfunc,
2204-
void *param) {
2203+
int putlocal(struct zlist *z, WRITEFUNC wfunc, void *param) {
22052204
PUTLG(LOCSIG, f);
22062205
PUTSH(z->ver, f);
22072206
PUTSH(z->lflg, f);
@@ -2408,20 +2407,20 @@ bool HasZipSuffix(const TCHAR *fn) {
24082407
class TZip {
24092408
public:
24102409
explicit TZip(const char *pwd) noexcept
2411-
: hfout(nullptr),
2410+
: password(nullptr),
2411+
hfout(nullptr),
24122412
mustclosehfout(false),
24132413
hmapout(nullptr),
2414-
zfis(nullptr),
2415-
obuf(nullptr),
2416-
hfin(nullptr),
2417-
writ(0),
2414+
ooffset(0),
24182415
oerr(ZR_OK),
2416+
writ(0),
2417+
obuf(nullptr),
24192418
hasputcen(false),
2420-
ooffset(0),
24212419
encwriting(false),
24222420
encbuf(nullptr),
2423-
password(nullptr),
2424-
state(nullptr) {
2421+
zfis(nullptr),
2422+
state(nullptr),
2423+
hfin(nullptr) {
24252424
memset(this, 0, sizeof(*this));
24262425

24272426
if (pwd && *pwd) {
@@ -3490,6 +3489,9 @@ size_t FormatZipMessageZ(ZRESULT code, char *buf, size_t len) {
34903489
case ZR_FLATE:
34913490
msg = "Zip-bug: an internal error during flation";
34923491
break;
3492+
default:
3493+
// Use default one.
3494+
break;
34933495
}
34943496

34953497
const size_t mlen{strlen(msg)};

0 commit comments

Comments
 (0)