mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-02 00:32:56 +02:00
Prevent certain APIs from returning 0 despite failing
This commit is contained in:
@@ -1854,18 +1854,20 @@ int GB_start_audio_recording(GB_gameboy_t *gb, const char *path, GB_audio_format
|
|||||||
case GB_AUDIO_FORMAT_AIFF: {
|
case GB_AUDIO_FORMAT_AIFF: {
|
||||||
aiff_header_t header = {0,};
|
aiff_header_t header = {0,};
|
||||||
if (fwrite(&header, sizeof(header), 1, gb->apu_output.output_file) != 1) {
|
if (fwrite(&header, sizeof(header), 1, gb->apu_output.output_file) != 1) {
|
||||||
|
int ret = errno ?: EIO;
|
||||||
fclose(gb->apu_output.output_file);
|
fclose(gb->apu_output.output_file);
|
||||||
gb->apu_output.output_file = NULL;
|
gb->apu_output.output_file = NULL;
|
||||||
return errno;
|
return ret;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case GB_AUDIO_FORMAT_WAV: {
|
case GB_AUDIO_FORMAT_WAV: {
|
||||||
wav_header_t header = {0,};
|
wav_header_t header = {0,};
|
||||||
if (fwrite(&header, sizeof(header), 1, gb->apu_output.output_file) != 1) {
|
if (fwrite(&header, sizeof(header), 1, gb->apu_output.output_file) != 1) {
|
||||||
|
int ret = errno ?: EIO;
|
||||||
fclose(gb->apu_output.output_file);
|
fclose(gb->apu_output.output_file);
|
||||||
gb->apu_output.output_file = NULL;
|
gb->apu_output.output_file = NULL;
|
||||||
return errno;
|
return ret;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -338,7 +338,6 @@ int GB_save_cheats(GB_gameboy_t *gb, const char *path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return errno;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
void GB_attributed_logv(GB_gameboy_t *gb, GB_log_attributes_t attributes, const char *fmt, va_list args)
|
void GB_attributed_logv(GB_gameboy_t *gb, GB_log_attributes_t attributes, const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
|
int errno_backup = errno;
|
||||||
char *string = NULL;
|
char *string = NULL;
|
||||||
vasprintf(&string, fmt, args);
|
vasprintf(&string, fmt, args);
|
||||||
if (string) {
|
if (string) {
|
||||||
@@ -27,6 +28,7 @@ void GB_attributed_logv(GB_gameboy_t *gb, GB_log_attributes_t attributes, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(string);
|
free(string);
|
||||||
|
errno = errno_backup;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GB_attributed_log(GB_gameboy_t *gb, GB_log_attributes_t attributes, const char *fmt, ...)
|
void GB_attributed_log(GB_gameboy_t *gb, GB_log_attributes_t attributes, const char *fmt, ...)
|
||||||
@@ -877,8 +879,7 @@ int GB_save_battery_to_buffer(GB_gameboy_t *gb, uint8_t *buffer, size_t size)
|
|||||||
memcpy(buffer + gb->mbc_ram_size, &rtc_save.vba64, sizeof(rtc_save.vba64));
|
memcpy(buffer + gb->mbc_ram_size, &rtc_save.vba64, sizeof(rtc_save.vba64));
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
return 0;
|
||||||
return errno;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GB_save_battery(GB_gameboy_t *gb, const char *path)
|
int GB_save_battery(GB_gameboy_t *gb, const char *path)
|
||||||
@@ -942,9 +943,8 @@ int GB_save_battery(GB_gameboy_t *gb, const char *path)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return errno;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void load_tpp1_save_data(GB_gameboy_t *gb, const tpp1_rtc_save_t *data)
|
static void load_tpp1_save_data(GB_gameboy_t *gb, const tpp1_rtc_save_t *data)
|
||||||
|
@@ -834,9 +834,8 @@ static int save_state_internal(GB_gameboy_t *gb, virtual_file_t *file, bool appe
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
error:
|
error:
|
||||||
return errno;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GB_save_state(GB_gameboy_t *gb, const char *path)
|
int GB_save_state(GB_gameboy_t *gb, const char *path)
|
||||||
|
Reference in New Issue
Block a user