diff --git a/src/state.cpp b/src/state.cpp index 75de75ac..90871905 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -133,7 +133,7 @@ static int SubWrite(EMUFILE* os, SFORMAT *sf) while(sf->v) { - if(sf->s==~0) //Link to another struct + if(sf->s==~0u) //Link to another struct { uint32 tmp; @@ -191,7 +191,7 @@ static SFORMAT *CheckS(SFORMAT *sf, uint32 tsize, char *desc) { while(sf->v) { - if(sf->s==~0) // Link to another SFORMAT structure. + if(sf->s==~0u) // Link to another SFORMAT structure. { SFORMAT *tmp; if((tmp= CheckS((SFORMAT *)sf->v, tsize, desc) )) @@ -427,7 +427,7 @@ bool FCEUSS_SaveMS(EMUFILE* outstream, int compressionLevel) if(SPostSave) SPostSave(); //save the length of the file - int len = memory_savestate.size(); + size_t len = memory_savestate.size(); //sanity check: len and totalsize should be the same if(len != totalsize) @@ -438,7 +438,7 @@ bool FCEUSS_SaveMS(EMUFILE* outstream, int compressionLevel) int error = Z_OK; uint8* cbuf = (uint8*)memory_savestate.buf(); - uLongf comprlen = -1; + uLongf comprlen = ~0lu; if(compressionLevel != Z_NO_COMPRESSION && (compressSavestates || FCEUMOV_Mode(MOVIEMODE_TASEDITOR))) { // worst case compression: zlib says "0.1% larger than sourceLen plus 12 bytes" @@ -457,7 +457,7 @@ bool FCEUSS_SaveMS(EMUFILE* outstream, int compressionLevel) //dump it to the destination file outstream->fwrite((char*)header,16); - outstream->fwrite((char*)cbuf,comprlen==-1?totalsize:comprlen); + outstream->fwrite((char*)cbuf,comprlen==~0lu?totalsize:comprlen); return error == Z_OK; } @@ -666,22 +666,22 @@ bool FCEUSS_LoadFP(EMUFILE* is, ENUM_SSLOADPARAMS params) return ret; } - int totalsize = FCEU_de32lsb(header + 4); - int stateversion = FCEU_de32lsb(header + 8); - int comprlen = FCEU_de32lsb(header + 12); + size_t totalsize = FCEU_de32lsb(header + 4); + int stateversion = FCEU_de32lsb(header + 8); + uint32_t comprlen = FCEU_de32lsb(header + 12); // reinit memory_savestate // memory_savestate is global variable which already has its vector of bytes, so no need to allocate memory every time we use save/loadstate - if ((int)(memory_savestate.get_vec())->size() < totalsize) + if ((memory_savestate.get_vec())->size() < totalsize) (memory_savestate.get_vec())->resize(totalsize); memory_savestate.set_len(totalsize); memory_savestate.unfail(); memory_savestate.fseek(0, SEEK_SET); - if(comprlen != -1) + if(comprlen != ~0u) { // the savestate is compressed: read from is to compressed_buf, then decompress from compressed_buf to memory_savestate.vec - if ((int)compressed_buf.size() < comprlen) compressed_buf.resize(comprlen); + if (compressed_buf.size() < comprlen) compressed_buf.resize(comprlen); is->fread(&compressed_buf[0], comprlen); uLongf uncomprlen = totalsize; @@ -874,7 +874,7 @@ void AddExState(void *v, uint32 s, int type, const char *desc) //do not accept extra state information if a null pointer was provided for v, so list won't terminate early if (v == 0) return; - if(s==~0) + if(s==~0u) { SFORMAT* sf = (SFORMAT*)v; std::map names;