Silence -Walloc-size-larger-than=byte-size
One of the GCC14's optimization heuristic triggered here, suggesting that the special value of len (size_t) could potentially be lesser than the file's size (int64_t) but greater than "maximum object size" (set by byte-size, PTRDIFF_MAX by default). Use the same type as the file size it's compared to, and adjust the sentinel value to spell INT64_MAX.
This commit is contained in:
parent
5c093a7211
commit
3dca8dbf66
|
@ -269,7 +269,7 @@ static int intfstream_get_serial(intfstream_t *fd, char *s, size_t len, const ch
|
|||
}
|
||||
|
||||
static bool intfstream_file_get_serial(const char *name,
|
||||
uint64_t offset, size_t size, char *s, size_t len)
|
||||
uint64_t offset, int64_t size, char *s, size_t len)
|
||||
{
|
||||
int rv;
|
||||
uint8_t *data = NULL;
|
||||
|
@ -291,7 +291,7 @@ static bool intfstream_file_get_serial(const char *name,
|
|||
if (file_size < 0)
|
||||
goto error;
|
||||
|
||||
if (offset != 0 || size < (size_t) file_size)
|
||||
if (offset != 0 || size < file_size)
|
||||
{
|
||||
if (intfstream_seek(fd, (int64_t)offset, SEEK_SET) == -1)
|
||||
goto error;
|
||||
|
@ -364,7 +364,7 @@ static int task_database_gdi_get_serial(const char *name, char *s, size_t len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return intfstream_file_get_serial(track_path, 0, SIZE_MAX, s, len);
|
||||
return intfstream_file_get_serial(track_path, 0, INT64_MAX, s, len);
|
||||
}
|
||||
|
||||
static int task_database_chd_get_serial(const char *name, char *serial, size_t len)
|
||||
|
@ -385,7 +385,7 @@ static int task_database_chd_get_serial(const char *name, char *serial, size_t l
|
|||
}
|
||||
|
||||
static bool intfstream_file_get_crc(const char *name,
|
||||
uint64_t offset, size_t len, uint32_t *crc)
|
||||
uint64_t offset, int64_t len, uint32_t *crc)
|
||||
{
|
||||
bool rv;
|
||||
intfstream_t *fd = intfstream_open_file(name,
|
||||
|
@ -407,7 +407,7 @@ static bool intfstream_file_get_crc(const char *name,
|
|||
if (file_size < 0)
|
||||
goto error;
|
||||
|
||||
if (offset != 0 || len < (uint64_t) file_size)
|
||||
if (offset != 0 || len < file_size)
|
||||
{
|
||||
if (intfstream_seek(fd, (int64_t)offset, SEEK_SET) == -1)
|
||||
goto error;
|
||||
|
@ -480,7 +480,7 @@ static int task_database_gdi_get_crc(const char *name, uint32_t *crc)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return intfstream_file_get_crc(track_path, 0, SIZE_MAX, crc);
|
||||
return intfstream_file_get_crc(track_path, 0, INT64_MAX, crc);
|
||||
}
|
||||
|
||||
static bool task_database_chd_get_crc(const char *name, uint32_t *crc)
|
||||
|
@ -624,7 +624,7 @@ static int task_database_iterate_playlist(
|
|||
db->type = DATABASE_TYPE_CRC_LOOKUP;
|
||||
/* first check crc of archive itself */
|
||||
return intfstream_file_get_crc(name,
|
||||
0, SIZE_MAX, &db_state->archive_crc);
|
||||
0, INT64_MAX, &db_state->archive_crc);
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
|
@ -656,7 +656,7 @@ static int task_database_iterate_playlist(
|
|||
case FILE_TYPE_WIA:
|
||||
case FILE_TYPE_ISO:
|
||||
db_state->serial[0] = '\0';
|
||||
intfstream_file_get_serial(name, 0, SIZE_MAX, db_state->serial, sizeof(db_state->serial));
|
||||
intfstream_file_get_serial(name, 0, INT64_MAX, db_state->serial, sizeof(db_state->serial));
|
||||
db->type = DATABASE_TYPE_SERIAL_LOOKUP;
|
||||
break;
|
||||
case FILE_TYPE_CHD:
|
||||
|
@ -675,7 +675,7 @@ static int task_database_iterate_playlist(
|
|||
default:
|
||||
db_state->serial[0] = '\0';
|
||||
db->type = DATABASE_TYPE_CRC_LOOKUP;
|
||||
return intfstream_file_get_crc(name, 0, SIZE_MAX, &db_state->crc);
|
||||
return intfstream_file_get_crc(name, 0, INT64_MAX, &db_state->crc);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -1136,7 +1136,7 @@ static int task_database_iterate_serial_lookup(
|
|||
if (task_database_check_serial_and_crc(db_state))
|
||||
{
|
||||
if (db_state->crc == 0)
|
||||
intfstream_file_get_crc(name, 0, SIZE_MAX, &db_state->crc);
|
||||
intfstream_file_get_crc(name, 0, INT64_MAX, &db_state->crc);
|
||||
if (db_state->crc == db_info_entry->crc32)
|
||||
return database_info_list_iterate_found_match(_db,
|
||||
db_state, db, NULL);
|
||||
|
|
Loading…
Reference in New Issue