From b7a126ac17bf947b5487a084c362302b2a91ea04 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Sun, 18 Nov 2018 12:03:14 -0600 Subject: [PATCH] Get rid of "ignore" warnings. --- logger.cpp | 10 ++++++---- memmap.cpp | 24 +++++++++++++----------- movie.cpp | 35 +++++++++++++++++++---------------- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/logger.cpp b/logger.cpp index 9ecd8d38..5db39a60 100644 --- a/logger.cpp +++ b/logger.cpp @@ -70,10 +70,12 @@ void S9xVideoLogger (void *pixels, int width, int height, int depth, int bytes_p if (video) { char *data = (char *) pixels; - size_t ignore; for (int i = 0; i < height; i++) - ignore = fwrite(data + i * bytes_per_line, depth, width, video); + { + if (!fwrite(data + i * bytes_per_line, depth, width, video)) + printf ("Error writing video data.\n"); + } fflush(video); fflush(audio); @@ -90,7 +92,7 @@ void S9xAudioLogger (void *samples, int length) { if (audio) { - size_t ignore; - ignore = fwrite(samples, 1, length, audio); + if (!fwrite(samples, 1, length, audio)) + printf ("Error writing audio data.\n"); } } diff --git a/memmap.cpp b/memmap.cpp index a65260b3..12088325 100644 --- a/memmap.cpp +++ b/memmap.cpp @@ -1879,13 +1879,13 @@ bool8 CMemory::LoadGNEXT () bool8 CMemory::LoadSRTC (void) { FILE *fp; - size_t ignore; fp = fopen(S9xGetFilename(".rtc", SRAM_DIR), "rb"); if (!fp) return (FALSE); - ignore = fread(RTCData.reg, 1, 20, fp); + if (fread(RTCData.reg, 1, 20, fp) < 20) + memset (RTCData.reg, 0, 20); fclose(fp); return (TRUE); @@ -1894,13 +1894,15 @@ bool8 CMemory::LoadSRTC (void) bool8 CMemory::SaveSRTC (void) { FILE *fp; - size_t ignore; fp = fopen(S9xGetFilename(".rtc", SRAM_DIR), "wb"); if (!fp) return (FALSE); - ignore = fwrite(RTCData.reg, 1, 20, fp); + if (fwrite(RTCData.reg, 1, 20, fp) < 20) + { + printf ("Failed to save clock data.\n"); + } fclose(fp); return (TRUE); @@ -2027,8 +2029,8 @@ bool8 CMemory::SaveSRAM (const char *filename) file = fopen(name, "wb"); if (file) { - size_t ignore; - ignore = fwrite((char *) Multi.sramB, size, 1, file); + if (!fwrite((char *) Multi.sramB, size, 1, file)) + printf ("Couldn't write to subcart SRAM file.\n"); fclose(file); } @@ -2044,8 +2046,8 @@ bool8 CMemory::SaveSRAM (const char *filename) file = fopen(sramName, "wb"); if (file) { - size_t ignore; - ignore = fwrite((char *) SRAM, size, 1, file); + if (!fwrite((char *) SRAM, size, 1, file)) + printf ("Couldn't write to SRAM file.\n"); fclose(file); if (Settings.SRTC || Settings.SPC7110RTC) @@ -2073,11 +2075,11 @@ bool8 CMemory::SaveMPAK (const char *filename) file = fopen(mempakName, "wb"); if (file) { - size_t ignore; - ignore = fwrite((char *)Memory.ROM + Multi.cartOffsetB, size, 1, file); + size_t written; + written = fwrite((char *)Memory.ROM + Multi.cartOffsetB, size, 1, file); fclose(file); - return (TRUE); + return (written > 0); } } } diff --git a/movie.cpp b/movie.cpp index 4c24fd43..c0a1afff 100644 --- a/movie.cpp +++ b/movie.cpp @@ -366,8 +366,8 @@ static void flush_movie (void) write_movie_header(Movie.File, &Movie); fseek(Movie.File, Movie.ControllerDataOffset, SEEK_SET); - size_t ignore; - ignore = fwrite(Movie.InputBuffer, 1, Movie.BytesPerSample * (Movie.MaxSample + 1), Movie.File); + if (!fwrite(Movie.InputBuffer, 1, Movie.BytesPerSample * (Movie.MaxSample + 1), Movie.File)) + printf ("Movie flush failed.\n"); } static void truncate_movie (void) @@ -378,8 +378,8 @@ static void truncate_movie (void) if (Movie.SaveStateOffset > Movie.ControllerDataOffset) return; - int ignore; - ignore = ftruncate(fileno(Movie.File), Movie.ControllerDataOffset + Movie.BytesPerSample * (Movie.MaxSample + 1)); + if (ftruncate(fileno(Movie.File), Movie.ControllerDataOffset + Movie.BytesPerSample * (Movie.MaxSample + 1))) + printf ("Couldn't truncate file.\n"); } static int read_movie_header (FILE *fd, SMovie *movie) @@ -465,8 +465,8 @@ static void write_movie_header (FILE *fd, SMovie *movie) Write8(movie->PortIDs[p][i], ptr); } - size_t ignore; - ignore = fwrite(buf, 1, SMV_HEADER_SIZE, fd); + if (!fwrite(buf, 1, SMV_HEADER_SIZE, fd)) + printf ("Couldn't write movie header.\n"); } static void write_movie_extrarominfo (FILE *fd, SMovie *movie) @@ -479,8 +479,7 @@ static void write_movie_extrarominfo (FILE *fd, SMovie *movie) Write32(movie->ROMCRC32, ptr); strncpy((char *) ptr, movie->ROMName, 23); - size_t ignore; - ignore = fwrite(buf, 1, SMV_EXTRAROMINFO_SIZE, fd); + fwrite(buf, 1, SMV_EXTRAROMINFO_SIZE, fd); } static void change_state (MovieState new_state) @@ -667,8 +666,12 @@ int S9xMovieOpen (const char *filename, bool8 read_only) Movie.InputBufferPtr = Movie.InputBuffer; reserve_buffer_space(Movie.BytesPerSample * (Movie.MaxSample + 1)); - size_t ignore; - ignore = fread(Movie.InputBufferPtr, 1, Movie.BytesPerSample * (Movie.MaxSample + 1), fd); + if (!fread(Movie.InputBufferPtr, 1, Movie.BytesPerSample * (Movie.MaxSample + 1), fd)) + { + printf ("Failed to read from movie file.\n"); + fclose(fd); + return (WRONG_FORMAT); + } // read "baseline" controller data if (Movie.MaxSample && Movie.MaxFrame) @@ -732,8 +735,8 @@ int S9xMovieCreate (const char *filename, uint8 controllers_mask, uint8 opts, co meta_buf[i * 2 + 1] = (uint8) ((c >> 8) & 0xff); } - size_t ignore; - ignore = fwrite(meta_buf, sizeof(uint16), metadata_length, fd); + if (!fwrite(meta_buf, sizeof(uint16), metadata_length, fd)) + printf ("Failed writing movie metadata.\n"); } Movie.ROMCRC32 = Memory.ROMCRC32; @@ -900,8 +903,8 @@ void S9xMovieUpdate (bool addFrame) if (addFrame) Movie.MaxFrame = ++Movie.CurrentFrame; - size_t ignore; - ignore = fwrite((Movie.InputBufferPtr - Movie.BytesPerSample), 1, Movie.BytesPerSample, Movie.File); + if (!fwrite((Movie.InputBufferPtr - Movie.BytesPerSample), 1, Movie.BytesPerSample, Movie.File)) + printf ("Error writing control data.\n"); break; } @@ -926,8 +929,8 @@ void S9xMovieUpdateOnReset (void) Movie.MaxSample = ++Movie.CurrentSample; Movie.MaxFrame = ++Movie.CurrentFrame; - size_t ignore; - ignore = fwrite((Movie.InputBufferPtr - Movie.BytesPerSample), 1, Movie.BytesPerSample, Movie.File); + if (!fwrite((Movie.InputBufferPtr - Movie.BytesPerSample), 1, Movie.BytesPerSample, Movie.File)) + printf ("Failed writing reset data.\n"); } }