This commit is contained in:
libretroadmin 2023-06-15 00:10:53 +02:00
parent 10995d509d
commit 86d5e4128c
10 changed files with 150 additions and 141 deletions

View file

@ -1404,7 +1404,7 @@ struct string_list* cdrom_get_available_drives(void)
if (string_split_noalloc(&mods, buf, "\n"))
{
for (i = 0; i < mods.size; i++)
for (i = 0; i < (int)mods.size; i++)
{
if (strcasestr(mods.elems[i].data, "sg "))
{
@ -1446,13 +1446,13 @@ struct string_list* cdrom_get_available_drives(void)
DWORD drive_mask = GetLogicalDrives();
int i;
for (i = 0; i < sizeof(DWORD) * 8; i++)
for (i = 0; i < (int)(sizeof(DWORD) * 8); i++)
{
char path[] = {"a:\\"};
char path[] = {"a:\\"};
char cdrom_path[] = {"cdrom://a:/drive-track01.bin"};
path[0] += i;
cdrom_path[8] += i;
path[0] += i;
cdrom_path[8] += i;
/* this drive letter doesn't exist */
if (!(drive_mask & (1 << i)))
@ -1460,15 +1460,14 @@ struct string_list* cdrom_get_available_drives(void)
if (GetDriveType(path) != DRIVE_CDROM)
continue;
else
{
char drive_model[32] = {0};
char drive_string[33] = {0};
libretro_vfs_implementation_file *stream;
bool is_cdrom = false;
char drive_model[32] = {0};
char drive_string[33] = {0};
union string_list_elem_attr attr = {0};
RFILE *file = filestream_open(cdrom_path, RETRO_VFS_FILE_ACCESS_READ, 0);
libretro_vfs_implementation_file *stream;
bool is_cdrom = false;
if (!file)
continue;
@ -1524,9 +1523,7 @@ bool cdrom_drive_has_media(const char drive)
if (file)
{
libretro_vfs_implementation_file *stream = filestream_get_vfs_handle(file);
bool has_media = false;
has_media = cdrom_is_media_inserted(stream);
bool has_media = cdrom_is_media_inserted(stream);
filestream_close(file);
@ -1538,14 +1535,14 @@ bool cdrom_drive_has_media(const char drive)
bool cdrom_set_read_cache(libretro_vfs_implementation_file *stream, bool enabled)
{
int i;
/* MMC Command: MODE SENSE (10) and MODE SELECT (10) */
unsigned char cdb_sense_changeable[] = {0x5A, 0, 0x48, 0, 0, 0, 0, 0, 0x14, 0};
unsigned char cdb_sense[] = {0x5A, 0, 0x8, 0, 0, 0, 0, 0, 0x14, 0};
unsigned char cdb_select[] = {0x55, 0x10, 0, 0, 0, 0, 0, 0, 0x14, 0};
unsigned char buf[20] = {0};
int rv, i;
rv = cdrom_send_command(stream, DIRECTION_IN, buf, sizeof(buf), cdb_sense_changeable, sizeof(cdb_sense_changeable), 0);
unsigned char cdb_sense[] = {0x5A, 0, 0x8, 0, 0, 0, 0, 0, 0x14, 0};
unsigned char cdb_select[] = {0x55, 0x10, 0, 0, 0, 0, 0, 0, 0x14, 0};
unsigned char buf[20] = {0};
int rv = cdrom_send_command(stream, DIRECTION_IN, buf, sizeof(buf),
cdb_sense_changeable, sizeof(cdb_sense_changeable), 0);
#ifdef CDROM_DEBUG
printf("[CDROM] mode sense changeable status code %d\n", rv);
@ -1581,9 +1578,7 @@ bool cdrom_set_read_cache(libretro_vfs_implementation_file *stream, bool enabled
printf("Mode sense data for caching mode page: ");
for (i = 0; i < (int)sizeof(buf); i++)
{
printf("%02X ", buf[i]);
}
printf("\n");
fflush(stdout);
@ -1596,7 +1591,7 @@ bool cdrom_set_read_cache(libretro_vfs_implementation_file *stream, bool enabled
if (enabled)
buf[10] &= ~1;
else
buf[10] |= 1;
buf[10] |= 1;
rv = cdrom_send_command(stream, DIRECTION_OUT, buf, sizeof(buf), cdb_select, sizeof(cdb_select), 0);
@ -1645,9 +1640,7 @@ bool cdrom_get_timeouts(libretro_vfs_implementation_file *stream, cdrom_group_ti
printf("Mode sense data for timeout groups: ");
for (i = 0; i < (int)sizeof(buf); i++)
{
printf("%02X ", buf[i]);
}
printf("\n");
@ -1669,8 +1662,8 @@ bool cdrom_get_timeouts(libretro_vfs_implementation_file *stream, cdrom_group_ti
bool cdrom_has_atip(libretro_vfs_implementation_file *stream)
{
/* MMC Command: READ TOC/PMA/ATIP */
unsigned char cdb[] = {0x43, 0x2, 0x4, 0, 0, 0, 0, 0x9, 0x30, 0};
unsigned char buf[32] = {0};
unsigned char cdb[] = {0x43, 0x2, 0x4, 0, 0, 0, 0, 0x9, 0x30, 0};
unsigned char buf[32] = {0};
unsigned short atip_len = 0;
int rv = cdrom_send_command(stream, DIRECTION_IN, buf, sizeof(buf), cdb, sizeof(cdb), 0);
@ -1680,7 +1673,10 @@ bool cdrom_has_atip(libretro_vfs_implementation_file *stream)
atip_len = buf[0] << 8 | buf[1];
#ifdef CDROM_DEBUG
printf("ATIP Length %d, Disc Type %d, Disc Sub-Type %d\n", atip_len, (buf[6] >> 6) & 0x1, ((buf[6] >> 5) & 0x1) << 2 | ((buf[6] >> 4) & 0x1) << 1 | ((buf[6] >> 3) & 0x1) << 0);
printf("ATIP Length %d, Disc Type %d, Disc Sub-Type %d\n",
atip_len,
(buf[6] >> 6) & 0x1,
((buf[6] >> 5) & 0x1) << 2 | ((buf[6] >> 4) & 0x1) << 1 | ((buf[6] >> 3) & 0x1) << 0);
#endif
if (atip_len < 5)
@ -1691,30 +1687,23 @@ bool cdrom_has_atip(libretro_vfs_implementation_file *stream)
void cdrom_device_fillpath(char *path, size_t len, char drive, unsigned char track, bool is_cue)
{
size_t pos = 0;
if (!path || len == 0)
return;
if (is_cue)
{
#ifdef _WIN32
pos = strlcpy(path, "cdrom://", len);
size_t pos = strlcpy(path, "cdrom://", len);
if (len > pos)
path[pos++] = drive;
pos = strlcat(path, ":/drive.cue", len);
#else
#ifdef __linux__
pos = strlcpy(path, "cdrom://drive", len);
size_t pos = strlcpy(path, "cdrom://drive", len);
if (len > pos + 1)
{
path[pos++] = drive;
path[pos] = '\0';
path[pos] = '\0';
}
pos = strlcat(path, ".cue", len);
#endif
#endif
@ -1722,22 +1711,18 @@ void cdrom_device_fillpath(char *path, size_t len, char drive, unsigned char tra
else
{
#ifdef _WIN32
pos = strlcpy(path, "cdrom://", len);
size_t pos = strlcpy(path, "cdrom://", len);
if (len > pos + 1)
{
path[pos++] = drive;
path[pos] = '\0';
path[pos] = '\0';
}
pos += snprintf(path + pos, len - pos, ":/drive-track%02d.bin", track);
#else
#ifdef __linux__
pos = strlcpy(path, "cdrom://drive", len);
size_t pos = strlcpy(path, "cdrom://drive", len);
if (len > pos)
path[pos++] = drive;
pos += snprintf(path + pos, len - pos, "-track%02d.bin", track);
#endif
#endif

View file

@ -833,11 +833,12 @@ void cpu_features_get_model_name(char *name, int len)
{
#if defined(CPU_X86) && !defined(__MACH__)
union {
int i[4];
unsigned char s[16];
int32_t i[4];
uint32_t u[4];
uint8_t s[16];
} flags;
int i, j;
size_t pos = 0;
int pos = 0;
bool start = false;
if (!name)
@ -845,7 +846,8 @@ void cpu_features_get_model_name(char *name, int len)
x86_cpuid(0x80000000, flags.i);
if (flags.i[0] < 0x80000004)
/* Check for additional cpuid attributes availability */
if (flags.u[0] < 0x80000004)
return;
for (i = 0; i < 3; i++)
@ -853,7 +855,7 @@ void cpu_features_get_model_name(char *name, int len)
memset(flags.i, 0, sizeof(flags.i));
x86_cpuid(0x80000002 + i, flags.i);
for (j = 0; j < sizeof(flags.s); j++)
for (j = 0; j < (int)sizeof(flags.s); j++)
{
if (!start && flags.s[j] == ' ')
continue;
@ -872,7 +874,7 @@ void cpu_features_get_model_name(char *name, int len)
}
end:
/* terminate our string */
if (pos < (size_t)len)
if (pos < len)
name[pos] = '\0';
#elif defined(__MACH__)
if (!name)

View file

@ -404,7 +404,7 @@ static int zip_parse_file_init(file_archive_transfer_t *state,
uint8_t footer_buf[1024];
uint8_t *footer = footer_buf;
int64_t read_pos = state->archive_size;
int64_t read_block = MIN(read_pos, sizeof(footer_buf));
int64_t read_block = MIN(read_pos, (ssize_t)sizeof(footer_buf));
int64_t directory_size, directory_offset;
zip_context_t *zip_context = NULL;

View file

@ -28,19 +28,25 @@ static void cdfs_determine_sector_size(cdfs_track_t* track)
/* The boot record or primary volume descriptor is always at sector 16 and will contain a "CD001" marker */
intfstream_seek(track->stream, toc_sector * 2352 + track->first_sector_offset, SEEK_SET);
if (intfstream_read(track->stream, buffer, sizeof(buffer)) < sizeof(buffer))
if (intfstream_read(track->stream, &buffer, sizeof(buffer)) != (int64_t)sizeof(buffer))
return;
/* if this is a CDROM-XA data source, the "CD001" tag will be 25 bytes into the sector */
if (buffer[25] == 0x43 && buffer[26] == 0x44 &&
buffer[27] == 0x30 && buffer[28] == 0x30 && buffer[29] == 0x31)
if ( buffer[25] == 0x43
&& buffer[26] == 0x44
&& buffer[27] == 0x30
&& buffer[28] == 0x30
&& buffer[29] == 0x31)
{
track->stream_sector_size = 2352;
track->stream_sector_size = 2352;
track->stream_sector_header_size = 24;
}
/* otherwise it should be 17 bytes into the sector */
else if (buffer[17] == 0x43 && buffer[18] == 0x44 &&
buffer[19] == 0x30 && buffer[20] == 0x30 && buffer[21] == 0x31)
else if (buffer[17] == 0x43
&& buffer[18] == 0x44
&& buffer[19] == 0x30
&& buffer[20] == 0x30
&& buffer[21] == 0x31)
{
track->stream_sector_size = 2352;
track->stream_sector_header_size = 16;
@ -48,14 +54,24 @@ static void cdfs_determine_sector_size(cdfs_track_t* track)
else
{
/* ISO-9660 says the first twelve bytes of a sector should be the sync pattern 00 FF FF FF FF FF FF FF FF FF FF 00 */
if (buffer[0] == 0 && buffer[1] == 0xFF && buffer[2] == 0xFF && buffer[3] == 0xFF &&
buffer[4] == 0xFF && buffer[5] == 0xFF && buffer[6] == 0xFF && buffer[7] == 0xFF &&
buffer[8] == 0xFF && buffer[9] == 0xFF && buffer[10] == 0xFF && buffer[11] == 0)
if (
buffer[ 0] == 0
&& buffer[ 1] == 0xFF
&& buffer[ 2] == 0xFF
&& buffer[ 3] == 0xFF
&& buffer[ 4] == 0xFF
&& buffer[ 5] == 0xFF
&& buffer[ 6] == 0xFF
&& buffer[ 7] == 0xFF
&& buffer[ 8] == 0xFF
&& buffer[ 9] == 0xFF
&& buffer[10] == 0xFF
&& buffer[11] == 0)
{
/* if we didn't find a CD001 tag, this format may predate ISO-9660 */
/* after the 12 byte sync pattern is three bytes identifying the sector and then one byte for the mode (total 16 bytes) */
track->stream_sector_size = 2352;
track->stream_sector_size = 2352;
track->stream_sector_header_size = 16;
}
}
@ -69,19 +85,19 @@ static void cdfs_determine_sector_size_from_file_size(cdfs_track_t* track)
if ((size % 2352) == 0)
{
/* raw tracks use all 2352 bytes and have a 24 byte header */
track->stream_sector_size = 2352;
track->stream_sector_size = 2352;
track->stream_sector_header_size = 24;
}
else if ((size % 2048) == 0)
{
/* cooked tracks eliminate all header/footer data */
track->stream_sector_size = 2048;
track->stream_sector_size = 2048;
track->stream_sector_header_size = 0;
}
else if ((size % 2336) == 0)
{
/* MODE 2 format without 16-byte sync data */
track->stream_sector_size = 2336;
track->stream_sector_size = 2336;
track->stream_sector_header_size = 8;
}
}
@ -89,9 +105,9 @@ static void cdfs_determine_sector_size_from_file_size(cdfs_track_t* track)
static void cdfs_seek_track_sector(cdfs_track_t* track, unsigned int sector)
{
intfstream_seek(track->stream,
sector * track->stream_sector_size +
track->stream_sector_header_size +
track->first_sector_offset, SEEK_SET);
sector * track->stream_sector_size
+ track->stream_sector_header_size
+ track->first_sector_offset, SEEK_SET);
}
void cdfs_seek_sector(cdfs_file_t* file, unsigned int sector)
@ -99,13 +115,13 @@ void cdfs_seek_sector(cdfs_file_t* file, unsigned int sector)
/* only allowed if open_file was called with a NULL path */
if (file->first_sector == 0)
{
if (sector != file->current_sector)
if (file->current_sector != (int)sector)
{
file->current_sector = sector;
file->current_sector = (int)sector;
file->sector_buffer_valid = 0;
}
file->pos = file->current_sector * 2048;
file->pos = sector * 2048;
file->current_sector_offset = 0;
}
}
@ -178,12 +194,16 @@ static int cdfs_find_file(cdfs_file_t* file, const char* path)
/* filename is 33 bytes into the record and
* the format is "FILENAME;version" or "DIRECTORY" */
if ((tmp[33 + path_length] == ';' || tmp[33 + path_length] == '\0') &&
strncasecmp((const char*)(tmp + 33), path, path_length) == 0)
if ( (tmp[33 + path_length] == ';'
|| (tmp[33 + path_length] == '\0'))
&& strncasecmp((const char*)(tmp + 33), path, path_length) == 0)
{
/* the file size is in bytes 10-13 of the record */
file->size = tmp[10] | (tmp[11] << 8)
| (tmp[12] << 16) | (tmp[13] << 24);
file->size =
(tmp[10])
| (tmp[11] << 8)
| (tmp[12] << 16)
| (tmp[13] << 24);
/* the file contents are in the sector identified
* in bytes 2-4 of the record */
@ -207,18 +227,18 @@ int cdfs_open_file(cdfs_file_t* file, cdfs_track_t* track, const char* path)
file->track = track;
file->current_sector = -1;
file->first_sector = -1;
if (path)
file->first_sector = cdfs_find_file(file, path);
else if (file->track->stream_sector_size)
{
file->first_sector = 0;
file->size = (intfstream_get_size(
file->size = (unsigned int)((intfstream_get_size(
file->track->stream) / file->track->stream_sector_size)
* 2048;
* 2048);
return 1;
}
else
file->first_sector = -1;
return (file->first_sector >= 0);
}
@ -252,9 +272,9 @@ int64_t cdfs_read_file(cdfs_file_t* file, void* buffer, uint64_t len)
memcpy(buffer,
&file->sector_buffer[file->current_sector_offset], remaining);
buffer = (char*)buffer + remaining;
buffer = (char*)buffer + remaining;
bytes_read += remaining;
len -= remaining;
len -= remaining;
file->current_sector_offset += remaining;
}
@ -279,7 +299,7 @@ int64_t cdfs_read_file(cdfs_file_t* file, void* buffer, uint64_t len)
++file->current_sector;
len -= 2048;
len -= 2048;
}
if (len > 0)
@ -299,19 +319,17 @@ int64_t cdfs_read_file(cdfs_file_t* file, void* buffer, uint64_t len)
void cdfs_close_file(cdfs_file_t* file)
{
/* Not really anything to do here, just
* clear out the first_sector so
* read() won't do anything */
if (file)
{
/* not really anything to do here, just
* clear out the first_sector so read() won't do anything */
file->first_sector = -1;
}
}
int64_t cdfs_get_size(cdfs_file_t* file)
{
if (!file || file->first_sector < 0)
return 0;
return file->size;
}
@ -319,7 +337,6 @@ int64_t cdfs_tell(cdfs_file_t* file)
{
if (!file || file->first_sector < 0)
return -1;
return file->pos;
}
@ -360,7 +377,7 @@ int64_t cdfs_seek(cdfs_file_t* file, int64_t offset, int whence)
new_sector = file->pos / 2048;
if (new_sector != file->current_sector)
{
file->current_sector = new_sector;
file->current_sector = new_sector;
file->sector_buffer_valid = false;
}
@ -374,7 +391,9 @@ static void cdfs_skip_spaces(const char** ptr)
}
static cdfs_track_t* cdfs_wrap_stream(
intfstream_t* stream, unsigned first_sector_offset, unsigned first_sector_index)
intfstream_t* stream,
unsigned first_sector_offset,
unsigned first_sector_index)
{
cdfs_track_t* track = NULL;
@ -442,7 +461,8 @@ static cdfs_track_t* cdfs_open_cue_track(
while (file_end > file && *file_end != ' ' && *file_end != '\t')
--file_end;
if (file[0] == '"' && file_end[-1] == '"')
if ( file[0] == '"'
&& file_end[-1] == '"')
{
++file;
--file_end;
@ -484,10 +504,10 @@ static cdfs_track_t* cdfs_open_cue_track(
}
else if (!strncasecmp(line, "INDEX", 5))
{
unsigned sector_offset;
unsigned min = 0, sec = 0, frame = 0;
unsigned index_number = 0;
unsigned sector_offset;
const char *index = line + 5;
const char *index = line + 5;
cdfs_skip_spaces(&index);
sscanf(index, "%u", &index_number);
@ -496,16 +516,16 @@ static cdfs_track_t* cdfs_open_cue_track(
cdfs_skip_spaces(&index);
sscanf(index, "%u:%u:%u", &min, &sec, &frame);
sector_offset = ((min * 60) + sec) * 75 + frame;
sector_offset -= previous_index_sector_offset;
track_offset += sector_offset * previous_sector_size;
previous_sector_size = sector_size;
sector_offset = ((min * 60) + sec) * 75 + frame;
sector_offset -= previous_index_sector_offset;
track_offset += sector_offset * previous_sector_size;
previous_sector_size = sector_size;
previous_index_sector_offset += sector_offset;
if (found_track && index_number == 1)
{
if ( strstr(current_track_path, "/") ||
strstr(current_track_path, "\\"))
if ( strstr(current_track_path, "/")
|| strstr(current_track_path, "\\"))
strncpy(track_path, current_track_path, sizeof(track_path));
else
{
@ -546,10 +566,8 @@ static cdfs_track_t* cdfs_open_cue_track(
#ifdef HAVE_CHD
static cdfs_track_t* cdfs_open_chd_track(const char* path, int32_t track_index)
{
intfstream_t* intf_stream;
cdfs_track_t* track;
intf_stream = intfstream_open_chd_track(path,
cdfs_track_t *track;
intfstream_t *intf_stream = intfstream_open_chd_track(path,
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE,
track_index);
if (!intf_stream)
@ -612,17 +630,17 @@ struct cdfs_track_t* cdfs_open_data_track(const char* path)
cdfs_track_t* cdfs_open_raw_track(const char* path)
{
const char* ext = path_get_extension(path);
cdfs_track_t* track = NULL;
const char *ext = path_get_extension(path);
cdfs_track_t *track = NULL;
if ( string_is_equal_noncase(ext, "bin") ||
string_is_equal_noncase(ext, "iso"))
if ( string_is_equal_noncase(ext, "bin")
|| string_is_equal_noncase(ext, "iso"))
{
intfstream_t* file = intfstream_open_file(path,
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE);
track = cdfs_wrap_stream(file, 0, 0);
if (track != NULL && track->stream_sector_size == 0)
if (track && track->stream_sector_size == 0)
{
cdfs_determine_sector_size_from_file_size(track);
if (track->stream_sector_size == 0)

View file

@ -421,6 +421,7 @@ static INLINE UINT32 get_bigendian_uint32(const UINT8 *base)
the data stream in bigendian order
-------------------------------------------------*/
#if 0
static INLINE void put_bigendian_uint32(UINT8 *base, UINT32 value)
{
base[0] = value >> 24;
@ -428,6 +429,7 @@ static INLINE void put_bigendian_uint32(UINT8 *base, UINT32 value)
base[2] = value >> 8;
base[3] = value;
}
#endif
/*-------------------------------------------------
put_bigendian_uint24 - write a UINT24 to
@ -491,6 +493,7 @@ static INLINE void map_extract(const UINT8 *base, map_entry *entry)
entry to the datastream
-------------------------------------------------*/
#if 0
static INLINE void map_assemble(UINT8 *base, map_entry *entry)
{
put_bigendian_uint64(&base[0], entry->offset);
@ -499,6 +502,7 @@ static INLINE void map_assemble(UINT8 *base, map_entry *entry)
base[14] = entry->length >> 16;
base[15] = entry->flags;
}
#endif
/*-------------------------------------------------
map_size_v5 - calculate CHDv5 map size
@ -637,7 +641,7 @@ static chd_error decompress_v5_map(chd_file* chd, chd_header* header)
return CHDERR_DECOMPRESSION_ERROR;
}
for (hunknum = 0; hunknum < header->hunkcount; hunknum++)
for (hunknum = 0; hunknum < (int)header->hunkcount; hunknum++)
{
uint8_t *rawmap = header->rawmap + (hunknum * 12);
if (repcount > 0)
@ -666,7 +670,7 @@ static chd_error decompress_v5_map(chd_file* chd, chd_header* header)
/* then iterate through the hunks and extract the needed data */
curoffset = firstoffs;
for (hunknum = 0; hunknum < header->hunkcount; hunknum++)
for (hunknum = 0; hunknum < (int)header->hunkcount; hunknum++)
{
uint8_t *rawmap = header->rawmap + (hunknum * 12);
uint64_t offset = curoffset;
@ -856,7 +860,7 @@ chd_error chd_open_file(RFILE *file, int mode, chd_file *parent, chd_file **chd)
/* find the codec interface */
if (newchd->header.version < 5)
{
for (intfnum = 0; intfnum < ARRAY_SIZE(codec_interfaces); intfnum++)
for (intfnum = 0; intfnum < (int)ARRAY_SIZE(codec_interfaces); intfnum++)
if (codec_interfaces[intfnum].compression == newchd->header.compression[0])
{
newchd->codecintf[0] = &codec_interfaces[intfnum];
@ -878,9 +882,9 @@ chd_error chd_open_file(RFILE *file, int mode, chd_file *parent, chd_file **chd)
{
int i, decompnum;
/* verify the compression types and initialize the codecs */
for (decompnum = 0; decompnum < ARRAY_SIZE(newchd->header.compression); decompnum++)
for (decompnum = 0; decompnum < (int)ARRAY_SIZE(newchd->header.compression); decompnum++)
{
for (i = 0 ; i < ARRAY_SIZE(codec_interfaces) ; i++)
for (i = 0 ; i < (int)ARRAY_SIZE(codec_interfaces); i++)
{
if (codec_interfaces[i].compression == newchd->header.compression[decompnum])
{
@ -1331,7 +1335,7 @@ static chd_error header_validate(const chd_header *header)
return CHDERR_INVALID_PARAMETER;
/* require a supported compression mechanism */
for (intfnum = 0; intfnum < ARRAY_SIZE(codec_interfaces); intfnum++)
for (intfnum = 0; intfnum < (int)ARRAY_SIZE(codec_interfaces); intfnum++)
if (codec_interfaces[intfnum].compression == header->compression[0])
break;
@ -1571,7 +1575,7 @@ static UINT8* hunk_read_compressed(chd_file *chd, UINT64 offset, size_t size)
return chd->file_cache + offset;
filestream_seek(chd->file, offset, SEEK_SET);
bytes = filestream_read(chd->file, chd->compressed, size);
if (bytes != size)
if (bytes != (int64_t)size)
return NULL;
return chd->compressed;
}
@ -1591,7 +1595,7 @@ static chd_error hunk_read_uncompressed(chd_file *chd, UINT64 offset, size_t siz
}
filestream_seek(chd->file, offset, SEEK_SET);
bytes = filestream_read(chd->file, dest, size);
if (bytes != size)
if (bytes != (int64_t)size)
return CHDERR_READ_ERROR;
return CHDERR_NONE;
}
@ -1825,7 +1829,7 @@ static chd_error map_read(chd_file *chd)
/* read the map entries in in chunks and extract to the map list */
fileoffset = chd->header.length;
for (i = 0; i < chd->header.totalhunks; i += MAP_STACK_ENTRIES)
for (i = 0; i < (int)chd->header.totalhunks; i += MAP_STACK_ENTRIES)
{
/* compute how many entries this time */
int entries = chd->header.totalhunks - i, j;

View file

@ -292,7 +292,7 @@ FLAC__StreamDecoderWriteStatus flac_decoder_write_callback(void *client_data, co
{
int16_t *dest = decoder->uncompressed_start[0] + decoder->uncompressed_offset * frame->header.channels;
for (sampnum = 0; sampnum < blocksize && decoder->uncompressed_offset < decoder->uncompressed_length; sampnum++, decoder->uncompressed_offset++)
for (chan = 0; chan < frame->header.channels; chan++)
for (chan = 0; chan < (int)frame->header.channels; chan++)
*dest++ = (int16_t)((((uint16_t)buffer[chan][sampnum]) << shift) | (((uint16_t)buffer[chan][sampnum]) >> shift));
}
@ -300,7 +300,7 @@ FLAC__StreamDecoderWriteStatus flac_decoder_write_callback(void *client_data, co
else
{
for (sampnum = 0; sampnum < blocksize && decoder->uncompressed_offset < decoder->uncompressed_length; sampnum++, decoder->uncompressed_offset++)
for (chan = 0; chan < frame->header.channels; chan++)
for (chan = 0; chan < (int)frame->header.channels; chan++)
if (decoder->uncompressed_start[chan] != NULL)
decoder->uncompressed_start[chan][decoder->uncompressed_offset] = (int16_t) ( (((uint16_t)(buffer[chan][sampnum])) << shift) | ( ((uint16_t)(buffer[chan][sampnum])) >> shift) );
}

View file

@ -191,7 +191,7 @@ enum huffman_error huffman_import_tree_rle(struct huffman_decoder* decoder, stru
numbits = 3;
/* loop until we read all the nodes */
for (curnode = 0; curnode < decoder->numcodes; )
for (curnode = 0; curnode < (int)decoder->numcodes; /* blank */)
{
/* a non-one value is just raw */
int nodebits = bitstream_read(bitbuf, numbits);
@ -217,7 +217,7 @@ enum huffman_error huffman_import_tree_rle(struct huffman_decoder* decoder, stru
}
/* make sure we ended up with the right number */
if (curnode != decoder->numcodes)
if (curnode != (int)decoder->numcodes)
return HUFFERR_INVALID_DATA;
/* assign canonical codes for all nodes based on their code lengths */
@ -279,7 +279,7 @@ enum huffman_error huffman_import_tree_huffman(struct huffman_decoder* decoder,
}
/* now process the rest of the data */
for (curcode = 0; curcode < decoder->numcodes; )
for (curcode = 0; curcode < (int)decoder->numcodes; /* blank */)
{
int value = huffman_decode_one(smallhuff, bitbuf);
if (value != 0)
@ -289,13 +289,13 @@ enum huffman_error huffman_import_tree_huffman(struct huffman_decoder* decoder,
int count = bitstream_read(bitbuf, 3) + 2;
if (count == 7+2)
count += bitstream_read(bitbuf, rlefullbits);
for ( ; count != 0 && curcode < decoder->numcodes; count--)
for (/* blank */; count != 0 && curcode < (int)decoder->numcodes; count--)
decoder->huffnode[curcode++].numbits = last;
}
}
/* make sure we ended up with the right number */
if (curcode != decoder->numcodes)
if (curcode != (int)decoder->numcodes)
{
delete_huffman_decoder(smallhuff);
return HUFFERR_INVALID_DATA;
@ -330,7 +330,7 @@ enum huffman_error huffman_compute_tree_from_histo(struct huffman_decoder* decod
uint32_t upperweight;
uint32_t lowerweight = 0;
uint32_t sdatacount = 0;
for (i = 0; i < decoder->numcodes; i++)
for (i = 0; i < (int)decoder->numcodes; i++)
sdatacount += decoder->datahisto[i];
/* binary search to achieve the optimum encoding */
@ -399,7 +399,7 @@ int huffman_build_tree(struct huffman_decoder* decoder, uint32_t totaldata, uint
memset(decoder->huffnode, 0,
decoder->numcodes * sizeof(decoder->huffnode[0]));
for (curcode = 0; curcode < decoder->numcodes; curcode++)
for (curcode = 0; curcode < (int)decoder->numcodes; curcode++)
if (decoder->datahisto[curcode] != 0)
{
list[listitems++] = &decoder->huffnode[curcode];
@ -466,7 +466,7 @@ int huffman_build_tree(struct huffman_decoder* decoder, uint32_t totaldata, uint
/* compute the number of bits in each code,
* and fill in another histogram */
for (curcode = 0; curcode < decoder->numcodes; curcode++)
for (curcode = 0; curcode < (int)decoder->numcodes; curcode++)
{
struct node_t *curnode;
struct node_t* node = &decoder->huffnode[curcode];
@ -504,7 +504,7 @@ enum huffman_error huffman_assign_canonical_codes(struct huffman_decoder* decode
/* build up a histogram of bit lengths */
int curcode, codelen;
uint32_t bithisto[33] = { 0 };
for (curcode = 0; curcode < decoder->numcodes; curcode++)
for (curcode = 0; curcode < (int)decoder->numcodes; curcode++)
{
struct node_t* node = &decoder->huffnode[curcode];
if (node->numbits > decoder->maxbits)
@ -524,7 +524,7 @@ enum huffman_error huffman_assign_canonical_codes(struct huffman_decoder* decode
}
/* now assign canonical codes */
for (curcode = 0; curcode < decoder->numcodes; curcode++)
for (curcode = 0; curcode < (int)decoder->numcodes; curcode++)
{
struct node_t* node = &decoder->huffnode[curcode];
if (node->numbits > 0)
@ -543,7 +543,7 @@ void huffman_build_lookup_table(struct huffman_decoder* decoder)
{
/* iterate over all codes */
int curcode;
for (curcode = 0; curcode < decoder->numcodes; curcode++)
for (curcode = 0; curcode < (int)decoder->numcodes; curcode++)
{
/* process all nodes which have non-zero bits */
struct node_t* node = &decoder->huffnode[curcode];

View file

@ -105,7 +105,7 @@ rxml_document_t *rxml_load_document(const char *path)
goto error;
memory_buffer[len] = '\0';
if (filestream_read(file, memory_buffer, len) != (size_t)len)
if (filestream_read(file, memory_buffer, len) != len)
goto error;
filestream_close(file);
@ -129,7 +129,7 @@ rxml_document_t *rxml_load_document_string(const char *str)
rxml_document_t *doc = NULL;
size_t stack_i = 0;
size_t level = 0;
int c = 0;
int i = 0;
char *valptr = NULL;
rxml_node_t *node = NULL;
struct rxml_attrib_node *attr = NULL;
@ -238,9 +238,9 @@ rxml_document_t *rxml_load_document_string(const char *str)
break;
case YXML_CONTENT:
for (c = 0; c < sizeof(x.data) && x.data[c]; ++c)
for (i = 0; i < (int)sizeof(x.data) && x.data[i]; i++)
{
*valptr = x.data[c];
*valptr = x.data[i];
++valptr;
}
break;
@ -260,9 +260,9 @@ rxml_document_t *rxml_load_document_string(const char *str)
break;
case YXML_ATTRVAL:
for (c = 0; c < sizeof(x.data) && x.data[c]; ++c)
for (i = 0; i < (int)sizeof(x.data) && x.data[i]; i++)
{
*valptr = x.data[c];
*valptr = x.data[i];
++valptr;
}
break;

View file

@ -142,7 +142,7 @@ chdstream_find_track_number(chd_file *fd, int32_t track, metadata_t *meta)
if (!chdstream_get_meta(fd, i, meta))
return false;
if (track == meta->track)
if (track == (int)meta->track)
{
meta->frame_offset = frame_offset;
return true;
@ -294,7 +294,7 @@ chdstream_load_hunk(chdstream_t *stream, uint32_t hunknum)
{
uint16_t *array;
if (hunknum == stream->hunknum)
if ((int)hunknum == stream->hunknum)
return true;
if (chd_read(stream->chd, hunknum, stream->hunkmem) != CHDERR_NONE)
@ -416,7 +416,7 @@ int64_t chdstream_seek(chdstream_t *stream, int64_t offset, int whence)
if (new_offset < 0)
return -1;
if (new_offset > stream->track_end)
if ((size_t)new_offset > stream->track_end)
new_offset = stream->track_end;
stream->offset = new_offset;

View file

@ -699,8 +699,8 @@ int64_t retro_vfs_file_read_impl(libretro_vfs_implementation_file *stream,
int64_t retro_vfs_file_write_impl(libretro_vfs_implementation_file *stream, const void *s, uint64_t len)
{
int64_t pos = 0;
size_t result = -1;
int64_t pos = 0;
ssize_t result = -1;
if (!stream)
return -1;