From 1bacc6d6af3e570134d416bffc00126eca57b2e3 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 13 Jul 2017 00:16:24 -0400 Subject: [PATCH] Fixed some compiler warnings with Visual Studio. --- src/archiver_iso9660.c | 22 +++++++++++----------- src/archiver_zip.c | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/archiver_iso9660.c b/src/archiver_iso9660.c index 310a703..98e10a2 100644 --- a/src/archiver_iso9660.c +++ b/src/archiver_iso9660.c @@ -344,19 +344,19 @@ static int iso_extractfilename(ISO9660Handle *handle, static int iso_readimage(ISO9660Handle *handle, PHYSFS_uint64 where, void *buffer, PHYSFS_uint64 len) { - int rc = -1; + PHYSFS_sint64 rc = -1; BAIL_IF_ERRPASS(!__PHYSFS_platformGrabMutex(handle->mutex), -1); - if (where != handle->currpos) - GOTO_IF_ERRPASS(!handle->io->seek(handle->io,where), unlockme); + if ((where != handle->currpos) && !handle->io->seek(handle->io,where)) + BAIL_MUTEX_ERRPASS(handle->mutex, -1); + rc = handle->io->read(handle->io, buffer, len); if (rc == -1) { handle->currpos = (PHYSFS_uint64) -1; - goto unlockme; + BAIL_MUTEX_ERRPASS(handle->mutex, -1); } /* if */ - handle->currpos += rc; + handle->currpos += (PHYSFS_uint64) rc; - unlockme: __PHYSFS_platformReleaseMutex(handle->mutex); return rc; } /* iso_readimage */ @@ -653,7 +653,7 @@ static PHYSFS_uint32 iso_file_read_mem(ISO9660FileHandle *filehandle, void *buffer, PHYSFS_uint64 len) { /* check remaining bytes & max obj which can be fetched */ - const PHYSFS_sint64 bytesleft = filehandle->filesize - filehandle->currpos; + const PHYSFS_uint64 bytesleft = filehandle->filesize - filehandle->currpos; if (bytesleft < len) len = bytesleft; @@ -691,15 +691,15 @@ static PHYSFS_uint32 iso_file_read_foreign(ISO9660FileHandle *filehandle, /* check remaining bytes & max obj which can be fetched */ const PHYSFS_sint64 bytesleft = filehandle->filesize - filehandle->currpos; - if (bytesleft < len) + if (((PHYSFS_uint64) bytesleft) < len) len = bytesleft; rc = filehandle->io->read(filehandle->io, buffer, len); BAIL_IF_ERRPASS(rc == -1, -1); filehandle->currpos += rc; /* i trust my internal book keeping */ - BAIL_IF(rc < len, PHYSFS_ERR_CORRUPT, -1); - return rc; + BAIL_IF(((PHYSFS_uint64) rc) < len, PHYSFS_ERR_CORRUPT, -1); + return (PHYSFS_uint32) rc; } /* iso_file_read_foreign */ @@ -709,7 +709,7 @@ static int iso_file_seek_foreign(ISO9660FileHandle *fhandle, PHYSFS_sint64 pos; BAIL_IF(offset < 0, PHYSFS_ERR_INVALID_ARGUMENT, 0); - BAIL_IF(offset >= fhandle->filesize, PHYSFS_ERR_PAST_EOF, 0); + BAIL_IF(((PHYSFS_uint64) offset) >= fhandle->filesize, PHYSFS_ERR_PAST_EOF, 0); pos = fhandle->startblock * 2048 + offset; BAIL_IF_ERRPASS(!fhandle->io->seek(fhandle->io, pos), -1); diff --git a/src/archiver_zip.c b/src/archiver_zip.c index bbb0e53..9b74132 100644 --- a/src/archiver_zip.c +++ b/src/archiver_zip.c @@ -354,7 +354,7 @@ static PHYSFS_sint64 ZIP_read(PHYSFS_Io *_io, void *buf, PHYSFS_uint64 len) finfo->compressed_position += (PHYSFS_uint32) br; finfo->stream.next_in = finfo->buffer; - finfo->stream.avail_in = (PHYSFS_uint32) br; + finfo->stream.avail_in = (unsigned int) br; } /* if */ } /* if */ @@ -815,9 +815,9 @@ static int zip_resolve_symlink(PHYSFS_Io *io, ZIPinfo *info, ZIPentry *entry) { initializeZStream(&stream); stream.next_in = compressed; - stream.avail_in = complen; + stream.avail_in = (unsigned int) complen; stream.next_out = (unsigned char *) path; - stream.avail_out = size; + stream.avail_out = (unsigned int) size; if (zlib_err(inflateInit2(&stream, -MAX_WBITS)) == Z_OK) { rc = zlib_err(inflate(&stream, Z_FINISH)); @@ -1537,7 +1537,7 @@ static int zip_parse_end_of_central_dir(ZIPinfo *info, /* offset of central directory */ BAIL_IF_ERRPASS(!readui32(io, &offset32), 0); *dir_ofs = (PHYSFS_uint64) offset32; - BAIL_IF(pos < (*dir_ofs + ui32), PHYSFS_ERR_CORRUPT, 0); + BAIL_IF(((PHYSFS_uint64) pos) < (*dir_ofs + ui32), PHYSFS_ERR_CORRUPT, 0); /* * For self-extracting archives, etc, there's crapola in the file