Fixed a few warnings for -Wunused-result with fread usage.

This commit is contained in:
harry 2023-01-29 12:32:47 -05:00
parent 4944faf618
commit 0a19794cec
4 changed files with 23 additions and 5 deletions

View File

@ -562,10 +562,18 @@ void FCEU_LoadGameSave(CartInfo *LocalHWInfo) {
std::string soot = FCEU_MakeFName(FCEUMKF_SAV, 0, "sav");
sp = FCEUD_UTF8fopen(soot, "rb");
if (sp != NULL) {
if (sp != NULL)
{
for (int x = 0; x < 4; x++)
{
if (LocalHWInfo->SaveGame[x])
fread(LocalHWInfo->SaveGame[x], 1, LocalHWInfo->SaveGameLen[x], sp);
{
if ( fread(LocalHWInfo->SaveGame[x], 1, LocalHWInfo->SaveGameLen[x], sp) != static_cast<size_t>(LocalHWInfo->SaveGameLen[x]) )
{
FCEU_printf("Warning save game data read came up short!\n");
}
}
}
}
}
}

View File

@ -23,6 +23,7 @@ THE SOFTWARE.
#include "emufile.h"
#include "utils/xstring.h"
#include <stdio.h>
#include <vector>
bool EMUFILE::readAllBytes(std::vector<u8>* dstbuf, const std::string& fname)
@ -84,7 +85,10 @@ void EMUFILE_FILE::truncate(size_t length)
#ifdef _MSC_VER
_chsize(_fileno(fp),length);
#else
ftruncate(fileno(fp),length);
if ( ftruncate(fileno(fp),length) != 0 )
{
printf("Warning: EMUFILE_FILE::truncate failed\n");
}
#endif
// this is probably wrong if mode is "wb"
fclose(fp);

View File

@ -132,7 +132,10 @@ void ApplyIPS(FILE *ips, FCEUFILE* fp)
memset(buf+fp->size,0,offset+size-fp->size);
fp->size=offset+size;
}
fread(buf+offset,1,size,ips);
if ( fread(buf+offset,1,size,ips) != static_cast<size_t>(size) )
{
FCEU_printf(" Warn IPS data read came up short!\n");
}
}
count++;
}

View File

@ -122,7 +122,10 @@ int FCEUNET_SendFile(uint8 cmd, char *fn)
FCEUX_fstat(fileno(fp),&sb);
len = sb.st_size;
buf = (char*)FCEU_dmalloc(len); //mbg merge 7/17/06 added cast
fread(buf, 1, len, fp);
if ( fread(buf, 1, len, fp) != static_cast<size_t>(len) )
{
FCEU_printf("Warning: FCEUNET_SendFile failed to load complete file.\n");
}
fclose(fp);
cbuf = (char*)FCEU_dmalloc(4 + len + len / 1000 + 12); //mbg merge 7/17/06 added cast