From e46a6e093ff5e809fe7cb869023d7d109e3f0a97 Mon Sep 17 00:00:00 2001 From: yabause Date: Mon, 10 Nov 2008 22:09:39 +0000 Subject: [PATCH] Patch by Magliocchetti Riccardo: fix some sign vs unsigned warnings casting signed variables / constants to unsigned types --- desmume/src/cflash.cpp | 8 ++++---- desmume/src/memorystream.h | 2 +- desmume/src/saves.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/desmume/src/cflash.cpp b/desmume/src/cflash.cpp index 89ff0c3c5..4830469b5 100644 --- a/desmume/src/cflash.cpp +++ b/desmume/src/cflash.cpp @@ -164,7 +164,7 @@ static void add_file(char *fname, FsEntry * entry, int fileLevel) { for (; j=strlen(fname)) break; + if ((size_t)(j+i+1)>=strlen(fname)) break; files[numFiles].ext[j] = fname[j+i+1]; } for (; j<3; j++) @@ -184,7 +184,7 @@ static void add_file(char *fname, FsEntry * entry, int fileLevel) { n = 0; j = 13; - for (i=0; icFileName); i++) { + for (i=0; (size_t)icFileName); i++) { if (j == 13) { n++; p = (char*)&files[numFiles-n].name[0]; @@ -213,7 +213,7 @@ static void add_file(char *fname, FsEntry * entry, int fileLevel) { for (; j=strlen(fname)) break; + if ((size_t)(j+i+1)>=strlen(fname)) break; files[numFiles].ext[j] = fname[j+i+1]; } for (; j<3; j++) @@ -795,7 +795,7 @@ cflash_write(unsigned int address,unsigned int data) { WRITE_FN( disk_image, §or_data[written], 512 - written); written += cur_write; - if ( cur_write == -1) { + if ( cur_write == (size_t)-1) { break; } } diff --git a/desmume/src/memorystream.h b/desmume/src/memorystream.h index 219817ac5..98be24b1c 100644 --- a/desmume/src/memorystream.h +++ b/desmume/src/memorystream.h @@ -186,7 +186,7 @@ private: throw new std::runtime_error("memory_streambuf is not expandable"); size_t newcapacity; - if(upto == -1) + if(upto == (size_t)-1) newcapacity = capacity + capacity/2 + 2; else newcapacity = std::max(upto,capacity); diff --git a/desmume/src/saves.cpp b/desmume/src/saves.cpp index 522d516e9..393db0080 100644 --- a/desmume/src/saves.cpp +++ b/desmume/src/saves.cpp @@ -674,7 +674,7 @@ static bool savestate_save(std::ostream* outstream, int compressionLevel) write32le(len,outstream); //uncompressed length write32le(comprlen,outstream); //compressed length (-1 if it is not compressed) - outstream->write((char*)cbuf,comprlen==-1?len:comprlen); + outstream->write((char*)cbuf,comprlen==(u32)-1?len:comprlen); if(cbuf != (uint8*)ms.buf()) delete[] cbuf; #ifdef HAVE_LIBZ return error == Z_OK;