Bug fix: GB_save_state always returned success

This commit is contained in:
Lior Halphon 2025-07-21 23:53:54 +03:00
parent cfbc7b481a
commit e69f6b8579
1 changed files with 4 additions and 1 deletions

View File

@ -551,6 +551,7 @@ static const uint8_t *get_header_bank(GB_gameboy_t *gb)
static int save_state_internal(GB_gameboy_t *gb, virtual_file_t *file, bool append_bess)
{
errno = 0;
if (file->write(file, GB_GET_SECTION(gb, header), GB_SECTION_SIZE(header)) != GB_SECTION_SIZE(header)) goto error;
if (!DUMP_SECTION(gb, file, core_state)) goto error;
if (!DUMP_SECTION(gb, file, dma )) goto error;
@ -838,8 +839,10 @@ static int save_state_internal(GB_gameboy_t *gb, virtual_file_t *file, bool appe
goto error;
}
return 0;;
error:
return 0;
if (errno == 0) return EIO;
return errno;
}
int GB_save_state(GB_gameboy_t *gb, const char *path)