From 8dfd3cff8d9d1395d1b67dc6a4ad8af2dede8f39 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 14 Aug 2017 21:15:58 -0400 Subject: [PATCH] Fixed some compiler warnings on Visual Studio. (and maybe made a few new ones...) --- src/physfs.c | 3 ++- src/physfs_archiver_zip.c | 14 +++++++------- src/physfs_platform_windows.c | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/physfs.c b/src/physfs.c index 0d355122..4396e19e 100644 --- a/src/physfs.c +++ b/src/physfs.c @@ -3043,8 +3043,9 @@ int PHYSFS_stat(const char *_fname, PHYSFS_Stat *stat) } /* PHYSFS_stat */ -int __PHYSFS_readAll(PHYSFS_Io *io, void *buf, const PHYSFS_uint64 len) +int __PHYSFS_readAll(PHYSFS_Io *io, void *buf, const size_t _len) { + const PHYSFS_uint64 len = (PHYSFS_uint64) _len; return (io->read(io, buf, len) == len); } /* __PHYSFS_readAll */ diff --git a/src/physfs_archiver_zip.c b/src/physfs_archiver_zip.c index 437de352..daa68729 100644 --- a/src/physfs_archiver_zip.c +++ b/src/physfs_archiver_zip.c @@ -747,7 +747,7 @@ static ZIPentry *zip_follow_symlink(PHYSFS_Io *io, ZIPinfo *info, char *path) static int zip_resolve_symlink(PHYSFS_Io *io, ZIPinfo *info, ZIPentry *entry) { - const PHYSFS_uint64 size = entry->uncompressed_size; + const size_t size = (size_t) entry->uncompressed_size; char *path = NULL; int rc = 0; @@ -768,7 +768,7 @@ static int zip_resolve_symlink(PHYSFS_Io *io, ZIPinfo *info, ZIPentry *entry) else /* symlink target path is compressed... */ { z_stream stream; - const PHYSFS_uint64 complen = entry->compressed_size; + const size_t complen = (size_t) entry->compressed_size; PHYSFS_uint8 *compressed = (PHYSFS_uint8*) __PHYSFS_smallAlloc(complen); if (compressed != NULL) { @@ -1223,8 +1223,8 @@ static PHYSFS_sint64 zip64_find_end_of_central_dir(PHYSFS_Io *io, /* Just try moving back at most 256k. Oh well. */ if ((offset < pos) && (pos > 4)) { - const PHYSFS_uint64 maxbuflen = 256 * 1024; - PHYSFS_uint64 len = pos - offset; + const size_t maxbuflen = 256 * 1024; + size_t len = pos - offset; PHYSFS_uint8 *buf = NULL; PHYSFS_sint32 i; @@ -1246,7 +1246,7 @@ static PHYSFS_sint64 zip64_find_end_of_central_dir(PHYSFS_Io *io, (buf[i+2] == 0x06) && (buf[i+3] == 0x06) ) { __PHYSFS_smallFree(buf); - return pos - (len - i); + return pos - ((PHYSFS_sint64) (len - i)); } /* if */ } /* for */ @@ -1542,10 +1542,10 @@ static PHYSFS_Io *ZIP_openRead(void *opaque, const char *filename) const char *ptr = strrchr(filename, '$'); if (ptr != NULL) { - const PHYSFS_uint64 len = (PHYSFS_uint64) (ptr - filename); + const size_t len = (size_t) (ptr - filename); char *str = (char *) __PHYSFS_smallAlloc(len + 1); BAIL_IF(!str, PHYSFS_ERR_OUT_OF_MEMORY, NULL); - memcpy(str, filename, (size_t) len); + memcpy(str, filename, len); str[len] = '\0'; entry = zip_find_entry(info, str); __PHYSFS_smallFree(str); diff --git a/src/physfs_platform_windows.c b/src/physfs_platform_windows.c index 3d8063e1..5fd28e32 100644 --- a/src/physfs_platform_windows.c +++ b/src/physfs_platform_windows.c @@ -59,7 +59,7 @@ if (str == NULL) \ w_assignto = NULL; \ else { \ - const PHYSFS_uint64 len = (PHYSFS_uint64) ((strlen(str) + 1) * 2); \ + const size_t len = (PHYSFS_uint64) ((strlen(str) + 1) * 2); \ w_assignto = (WCHAR *) __PHYSFS_smallAlloc(len); \ if (w_assignto != NULL) \ PHYSFS_utf8ToUtf16(str, (PHYSFS_uint16 *) w_assignto, len); \