diff --git a/libgambatte/src/file/unzip/crypt.h b/libgambatte/src/file/unzip/crypt.h index 7d8597c2..4141ae99 100644 --- a/libgambatte/src/file/unzip/crypt.h +++ b/libgambatte/src/file/unzip/crypt.h @@ -32,8 +32,9 @@ /*********************************************************************** * Return the next byte in the pseudo-random sequence */ -static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab __attribute__((unused))) +static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) { + (void)pcrc_32_tab; unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an * unpredictable manner on 16-bit systems; not a problem * with any known compiler so far, though */ diff --git a/libgambatte/src/file/unzip/ioapi.c b/libgambatte/src/file/unzip/ioapi.c index 84795e34..3ada75e8 100644 --- a/libgambatte/src/file/unzip/ioapi.c +++ b/libgambatte/src/file/unzip/ioapi.c @@ -13,8 +13,6 @@ #include #include "ioapi.h" - - /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ #ifndef SEEK_CUR @@ -65,11 +63,9 @@ int ZCALLBACK ferror_file_func OF(( voidpf stream)); -voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) - voidpf opaque __attribute__((unused)); - const char* filename; - int mode; +voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) { + (void)opaque; FILE* file = NULL; const char* mode_fopen = NULL; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) @@ -87,44 +83,34 @@ voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) } -uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) - voidpf opaque __attribute__((unused)); - voidpf stream; - void* buf; - uLong size; +uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) { + (void)opaque; uLong ret; ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); return ret; } -uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) - voidpf opaque __attribute__((unused)); - voidpf stream; - const void* buf; - uLong size; +uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) { + (void)opaque; uLong ret; ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); return ret; } -long ZCALLBACK ftell_file_func (opaque, stream) - voidpf opaque __attribute__((unused)); - voidpf stream; +long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) { + (void)opaque; long ret; ret = ftell((FILE *)stream); return ret; } -long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) - voidpf opaque __attribute__((unused)); - voidpf stream; - uLong offset; - int origin; +long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) { + (void)opaque; int fseek_origin=0; long ret; switch (origin) @@ -145,26 +131,23 @@ long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) return ret; } -int ZCALLBACK fclose_file_func (opaque, stream) - voidpf opaque __attribute__((unused)); - voidpf stream; +int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) { + (void)opaque; int ret; ret = fclose((FILE *)stream); return ret; } -int ZCALLBACK ferror_file_func (opaque, stream) - voidpf opaque __attribute__((unused)); - voidpf stream; +int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) { + (void)opaque; int ret; ret = ferror((FILE *)stream); return ret; } -void fill_fopen_filefunc (pzlib_filefunc_def) - zlib_filefunc_def* pzlib_filefunc_def; +void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen_file = fopen_file_func; pzlib_filefunc_def->zread_file = fread_file_func; diff --git a/libgambatte/src/statesaver.cpp b/libgambatte/src/statesaver.cpp index 501f5c42..78524fcb 100644 --- a/libgambatte/src/statesaver.cpp +++ b/libgambatte/src/statesaver.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -550,10 +551,10 @@ bool StateSaver::saveState(SaveState const &state, return false; std::size_t size = saveState(state, videoBuf, pitch, NULL, mode); - char stateBuf[size]; + std::unique_ptr stateBuf {new char[size]}; - saveState(state, videoBuf, pitch, stateBuf, mode); - file.write(stateBuf, size); + saveState(state, videoBuf, pitch, stateBuf.get(), mode); + file.write(stateBuf.get(), size); return !file.fail(); }