Skip to content

Commit

Permalink
Avert minizip warnings for MSVC.
Browse files Browse the repository at this point in the history
  • Loading branch information
madler committed Mar 29, 2024
1 parent d201f04 commit 0f51fb4
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 37 deletions.
16 changes: 12 additions & 4 deletions contrib/minizip/iowin32.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static voidpf win32_build_iowin(HANDLE hFile) {
}

voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) {
const char* mode_fopen = NULL;
(void)opaque;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;

Expand Down Expand Up @@ -117,7 +117,7 @@ voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int


voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) {
const char* mode_fopen = NULL;
(void)opaque;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;

Expand All @@ -140,7 +140,7 @@ voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, in


voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) {
const char* mode_fopen = NULL;
(void)opaque;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;

Expand All @@ -159,7 +159,7 @@ voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, in


voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int mode) {
const char* mode_fopen = NULL;
(void)opaque;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;

Expand Down Expand Up @@ -187,6 +187,7 @@ voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int m


uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) {
(void)opaque;

This comment has been minimized.

Copy link
@tbeu

tbeu Apr 28, 2024

Contributor

Note, that these kind of declarations reintroduce #668. Let us know if you are interested in a patch.

uLong ret=0;
HANDLE hFile = NULL;
if (stream!=NULL)
Expand All @@ -208,6 +209,7 @@ uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLo


uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
(void)opaque;
uLong ret=0;
HANDLE hFile = NULL;
if (stream!=NULL)
Expand Down Expand Up @@ -247,6 +249,7 @@ static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *n
}

long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
(void)opaque;
long ret=-1;
HANDLE hFile = NULL;
if (stream!=NULL)
Expand All @@ -269,6 +272,7 @@ long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
}

ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {
(void)opaque;
ZPOS64_T ret= (ZPOS64_T)-1;
HANDLE hFile = NULL;
if (stream!=NULL)
Expand All @@ -293,6 +297,7 @@ ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {


long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
(void)opaque;
DWORD dwMoveMethod=0xFFFFFFFF;
HANDLE hFile = NULL;

Expand Down Expand Up @@ -330,6 +335,7 @@ long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset,
}

long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
(void)opaque;
DWORD dwMoveMethod=0xFFFFFFFF;
HANDLE hFile = NULL;
long ret=-1;
Expand Down Expand Up @@ -368,6 +374,7 @@ long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T off
}

int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
(void)opaque;
int ret=-1;

if (stream!=NULL)
Expand All @@ -385,6 +392,7 @@ int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
}

int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) {
(void)opaque;
int ret=-1;
if (stream!=NULL)
{
Expand Down
4 changes: 4 additions & 0 deletions contrib/minizip/miniunz.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#endif


#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -83,6 +86,7 @@
tmu_date : the SAME new date at the tm_unz format */
static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) {
#ifdef _WIN32
(void)tmu_date;
HANDLE hFile;
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;

Expand Down
10 changes: 7 additions & 3 deletions contrib/minizip/minizip.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@



#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -74,6 +77,7 @@
/* f: name of file to get info on, tmzip: return value: access,
modification and creation times, dt: dostime */
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
(void)tmzip;
int ret = 0;
{
FILETIME ftLocal;
Expand Down Expand Up @@ -190,7 +194,7 @@ static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_b
do
{
err = ZIP_OK;
size_read = fread(buf,1,size_buf,fin);
size_read = (unsigned long)fread(buf,1,size_buf,fin);
if (size_read < size_buf)
if (feof(fin)==0)
{
Expand Down Expand Up @@ -242,7 +246,7 @@ int main(int argc, char *argv[]) {
char filename_try[MAXFILENAME+16];
int zipok;
int err=0;
size_t size_buf=0;
unsigned long size_buf=0;
void* buf=NULL;
const char* password=NULL;

Expand Down Expand Up @@ -304,7 +308,7 @@ int main(int argc, char *argv[]) {
}
else
{
int i,len;
int len;
int dot_found=0;

zipok = 1 ;
Expand Down
61 changes: 32 additions & 29 deletions contrib/minizip/mztools.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/

/* Code */
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -140,28 +143,28 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*

/* Central directory entry */
{
char header[46];
char central[46];
char* comment = "";
int comsize = (int) strlen(comment);
WRITE_32(header, 0x02014b50);
WRITE_16(header + 4, version);
WRITE_16(header + 6, version);
WRITE_16(header + 8, gpflag);
WRITE_16(header + 10, method);
WRITE_16(header + 12, filetime);
WRITE_16(header + 14, filedate);
WRITE_32(header + 16, crc);
WRITE_32(header + 20, cpsize);
WRITE_32(header + 24, uncpsize);
WRITE_16(header + 28, fnsize);
WRITE_16(header + 30, extsize);
WRITE_16(header + 32, comsize);
WRITE_16(header + 34, 0); /* disk # */
WRITE_16(header + 36, 0); /* int attrb */
WRITE_32(header + 38, 0); /* ext attrb */
WRITE_32(header + 42, currentOffset);
WRITE_32(central, 0x02014b50);
WRITE_16(central + 4, version);
WRITE_16(central + 6, version);
WRITE_16(central + 8, gpflag);
WRITE_16(central + 10, method);
WRITE_16(central + 12, filetime);
WRITE_16(central + 14, filedate);
WRITE_32(central + 16, crc);
WRITE_32(central + 20, cpsize);
WRITE_32(central + 24, uncpsize);
WRITE_16(central + 28, fnsize);
WRITE_16(central + 30, extsize);
WRITE_16(central + 32, comsize);
WRITE_16(central + 34, 0); /* disk # */
WRITE_16(central + 36, 0); /* int attrb */
WRITE_32(central + 38, 0); /* ext attrb */
WRITE_32(central + 42, currentOffset);
/* Header */
if (fwrite(header, 1, 46, fpOutCD) == 46) {
if (fwrite(central, 1, 46, fpOutCD) == 46) {
offsetCD += 46;

/* Filename */
Expand Down Expand Up @@ -215,23 +218,23 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
/* Final central directory */
{
int entriesZip = entries;
char header[22];
char end[22];
char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
int comsize = (int) strlen(comment);
if (entriesZip > 0xffff) {
entriesZip = 0xffff;
}
WRITE_32(header, 0x06054b50);
WRITE_16(header + 4, 0); /* disk # */
WRITE_16(header + 6, 0); /* disk # */
WRITE_16(header + 8, entriesZip); /* hack */
WRITE_16(header + 10, entriesZip); /* hack */
WRITE_32(header + 12, offsetCD); /* size of CD */
WRITE_32(header + 16, offset); /* offset to CD */
WRITE_16(header + 20, comsize); /* comment */
WRITE_32(end, 0x06054b50);
WRITE_16(end + 4, 0); /* disk # */
WRITE_16(end + 6, 0); /* disk # */
WRITE_16(end + 8, entriesZip); /* hack */
WRITE_16(end + 10, entriesZip); /* hack */
WRITE_32(end + 12, offsetCD); /* size of CD */
WRITE_32(end + 16, offset); /* offset to CD */
WRITE_16(end + 20, comsize); /* comment */

/* Header */
if (fwrite(header, 1, 22, fpOutCD) == 22) {
if (fwrite(end, 1, 22, fpOutCD) == 22) {

/* Comment field */
if (comsize > 0) {
Expand Down
2 changes: 1 addition & 1 deletion contrib/minizip/unzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) {
uInt i;
for(i=0;i<uReadThis;i++)
pfile_in_zip_read_info->read_buffer[i] =
zdecode(s->keys,s->pcrc_32_tab,
(char)zdecode(s->keys,s->pcrc_32_tab,
pfile_in_zip_read_info->read_buffer[i]);
}
# endif
Expand Down

0 comments on commit 0f51fb4

Please sign in to comment.