Try silencing more warnings - do something with return value

This commit is contained in:
twinaphex 2017-09-26 03:51:50 +02:00
parent 581ef744d7
commit 6cf6d46e4b
2 changed files with 48 additions and 26 deletions

View File

@ -277,17 +277,24 @@ static bool intfstream_file_get_serial(const char *name, size_t offset, size_t s
if (!fd)
return 0;
intfstream_seek(fd, 0, SEEK_END);
if (intfstream_seek(fd, 0, SEEK_END) == -1)
goto error;
file_size = intfstream_tell(fd);
intfstream_seek(fd, 0, SEEK_SET);
if (intfstream_seek(fd, 0, SEEK_SET) == -1)
goto error;
if (file_size < 0)
goto error;
if (offset != 0 || size < (size_t) file_size)
{
if (intfstream_seek(fd, offset, SEEK_SET) == -1)
goto error;
data = (uint8_t*)malloc(size);
intfstream_seek(fd, offset, SEEK_SET);
if (intfstream_read(fd, data, size) != (ssize_t) size)
{
free(data);
@ -415,38 +422,33 @@ static bool intfstream_file_get_crc(const char *name,
if (!fd)
return 0;
intfstream_seek(fd, 0, SEEK_END);
if (intfstream_seek(fd, 0, SEEK_END) == -1)
goto error;
file_size = intfstream_tell(fd);
intfstream_seek(fd, 0, SEEK_SET);
if (intfstream_seek(fd, 0, SEEK_SET) == -1)
goto error;
if (file_size < 0)
{
intfstream_close(fd);
free(fd);
return 0;
}
goto error;
if (offset != 0 || size < (size_t) file_size)
{
if (intfstream_seek(fd, offset, SEEK_SET) == -1)
goto error;
data = (uint8_t*)malloc(size);
intfstream_seek(fd, offset, SEEK_SET);
if (intfstream_read(fd, data, size) != (ssize_t) size)
{
intfstream_close(fd);
free(fd);
free(data);
return 0;
}
goto error;
intfstream_close(fd);
free(fd);
fd = open_memory(data, size);
if (!fd)
{
free(data);
return 0;
}
goto error;
}
rv = intfstream_get_crc(fd, crc);
@ -454,6 +456,16 @@ static bool intfstream_file_get_crc(const char *name,
free(fd);
free(data);
return rv;
error:
if (fd)
{
intfstream_close(fd);
free(fd);
}
if (data)
free(data);
return 0;
}
static int task_database_cue_get_crc(const char *name, uint32_t *crc)

View File

@ -134,7 +134,9 @@ static int detect_ps1_game_sub(intfstream_t *fp,
buffer[0] = '\0';
is_mode1 = 0;
intfstream_seek(fp, 0, SEEK_END);
if (intfstream_seek(fp, 0, SEEK_END) == -1)
goto error;
if (!sub_channel_mixed)
{
@ -142,7 +144,9 @@ static int detect_ps1_game_sub(intfstream_t *fp,
{
unsigned int mode_test = 0;
intfstream_seek(fp, 0, SEEK_SET);
if (intfstream_seek(fp, 0, SEEK_SET) == -1)
goto error;
intfstream_read(fp, &mode_test, 4);
if (mode_test != MODETEST_VAL)
is_mode1 = 1;
@ -152,11 +156,15 @@ static int detect_ps1_game_sub(intfstream_t *fp,
skip = is_mode1? 0: 24;
frame_size = sub_channel_mixed? 2448: is_mode1? 2048: 2352;
intfstream_seek(fp, 156 + skip + 16 * frame_size, SEEK_SET);
if (intfstream_seek(fp, 156 + skip + 16 * frame_size, SEEK_SET) == -1)
goto error;
intfstream_read(fp, buffer, 6);
cd_sector = buffer[2] | (buffer[3] << 8) | (buffer[4] << 16);
intfstream_seek(fp, skip + cd_sector * frame_size, SEEK_SET);
if (intfstream_seek(fp, skip + cd_sector * frame_size, SEEK_SET) == -1)
goto error;
intfstream_read(fp, buffer, 2048 * 2);
tmp = buffer;
@ -175,7 +183,9 @@ static int detect_ps1_game_sub(intfstream_t *fp,
goto error;
cd_sector = tmp[2] | (tmp[3] << 8) | (tmp[4] << 16);
intfstream_seek(fp, skip + cd_sector * frame_size, SEEK_SET);
if (intfstream_seek(fp, skip + cd_sector * frame_size, SEEK_SET) == -1)
goto error;
intfstream_read(fp, buffer, 256);
buffer[256] = '\0';