MSVC buildfixes

This commit is contained in:
twinaphex 2017-09-19 21:29:28 +02:00
parent b3a45a9899
commit e8f39f004e
3 changed files with 73 additions and 83 deletions

View File

@ -410,10 +410,10 @@ static enum msg_file_type file_type(const char *path)
static int dir_entry_compare(const void *left, const void *right)
{
const struct string_list_elem *le = left;
const struct string_list_elem *re = right;
bool l = type_is_prioritized(file_type(le->data));
bool r = type_is_prioritized(file_type(re->data));
const struct string_list_elem *le = (const struct string_list_elem*)left;
const struct string_list_elem *re = (const struct string_list_elem*)right;
bool l = type_is_prioritized(file_type(le->data));
bool r = type_is_prioritized(file_type(re->data));
return (int) r - (int) l;
}
@ -426,7 +426,6 @@ static void dir_list_prioritize(struct string_list *list)
database_info_handle_t *database_info_dir_init(const char *dir,
enum database_type type, retro_task_t *task)
{
unsigned i;
database_info_handle_t *db = (database_info_handle_t*)
calloc(1, sizeof(*db));

View File

@ -91,7 +91,7 @@ static intfstream_t* open_file(const char *path)
intfstream_t *fd = NULL;
info.type = INTFSTREAM_FILE;
fd = intfstream_init(&info);
fd = (intfstream_t*)intfstream_init(&info);
if (!fd)
return NULL;
@ -105,22 +105,20 @@ static intfstream_t* open_file(const char *path)
return fd;
}
static intfstream_t*
open_memory(void *data, size_t size)
static intfstream_t *open_memory(void *data, size_t size)
{
intfstream_info_t info;
intfstream_t *fd = NULL;
intfstream_t *fd = NULL;
info.type = INTFSTREAM_MEMORY;
info.memory.buf.data = data;
info.type = INTFSTREAM_MEMORY;
info.memory.buf.data = (uint8_t*)data;
info.memory.buf.size = size;
info.memory.writable = false;
fd = intfstream_init(&info);
fd = (intfstream_t*)intfstream_init(&info);
if (!fd)
{
return NULL;
}
if (!intfstream_open(fd, NULL, RFILE_MODE_READ, -1))
{
@ -140,7 +138,7 @@ open_chd_track(const char *path, int32_t track)
info.type = INTFSTREAM_CHD;
info.chd.track = track;
fd = intfstream_init(&info);
fd = (intfstream_t*)intfstream_init(&info);
if (!fd)
return NULL;
@ -283,7 +281,7 @@ static bool file_get_serial(const char *name, size_t offset, size_t size, char *
if (offset != 0 || size < (size_t) file_size)
{
data = malloc(size);
data = (uint8_t*)malloc(size);
intfstream_seek(fd, offset, SEEK_SET);
if (intfstream_read(fd, data, size) != (ssize_t) size)
{
@ -402,35 +400,40 @@ static int stream_get_crc(intfstream_t *fd, uint32_t *crc)
static bool file_get_crc(const char *name, size_t offset, size_t size, uint32_t *crc)
{
intfstream_t *fd = open_file(name);
int rv;
uint8_t *data = NULL;
intfstream_t *fd = open_file(name);
uint8_t *data = NULL;
ssize_t file_size = -1;
if (!fd)
{
return 0;
}
intfstream_seek(fd, 0, SEEK_END);
file_size = intfstream_tell(fd);
intfstream_seek(fd, 0, SEEK_SET);
if (file_size < 0) {
if (file_size < 0)
{
intfstream_close(fd);
return 0;
}
if (offset != 0 || size < (size_t) file_size) {
data = malloc(size);
if (offset != 0 || size < (size_t) file_size)
{
data = (uint8_t*)malloc(size);
intfstream_seek(fd, offset, SEEK_SET);
if (intfstream_read(fd, data, size) != (ssize_t) size) {
if (intfstream_read(fd, data, size) != (ssize_t) size)
{
intfstream_close(fd);
free(data);
return 0;
}
intfstream_close(fd);
fd = open_memory(data, size);
if (!fd) {
if (!fd)
{
free(data);
return 0;
}
@ -504,20 +507,15 @@ static int gdi_get_crc(const char *name, uint32_t *crc)
static bool chd_get_crc(const char *name, uint32_t *crc)
{
intfstream_t *fd = NULL;
int rv;
uint32_t acc = 0;
uint8_t buffer[4096];
ssize_t size;
fd = open_chd_track(name, CHDSTREAM_TRACK_PRIMARY);
uint32_t acc = 0;
intfstream_t *fd = open_chd_track(name, CHDSTREAM_TRACK_PRIMARY);
if (!fd)
{
return 0;
}
rv = stream_get_crc(fd, crc);
if (rv == 1) {
if (rv == 1)
{
RARCH_LOG("CHD '%s' crc: %x\n", name, *crc);
}
intfstream_close(fd);
@ -847,14 +845,12 @@ static int task_database_iterate_crc_lookup(
if (db_state->entry_index == 0)
{
bool db_supports_content;
bool unsupported_content;
char query[50];
query[0] = '\0';
/* don't scan files that can't be in this database */
if(!core_info_database_supports_content_path(
if (!core_info_database_supports_content_path(
db_state->list->elems[db_state->list_index].data, name))
return database_info_list_iterate_next(db_state);

View File

@ -395,8 +395,10 @@ static bool update_cand(ssize_t *cand_index, ssize_t *last_index,
size_t *largest, char *last_file, size_t *offset,
size_t *size, char *track_path, size_t max_len)
{
if (*cand_index != -1) {
if (*last_index - *cand_index > *largest) {
if (*cand_index != -1)
{
if ((unsigned)(*last_index - *cand_index) > *largest)
{
*largest = *last_index - *cand_index;
strlcpy(track_path, last_file, max_len);
*offset = *cand_index;
@ -413,29 +415,27 @@ int cue_find_track(const char *cue_path, bool first,
size_t *offset, size_t *size, char *track_path, size_t max_len)
{
int rv;
char *tmp_token = malloc(MAX_TOKEN_LEN);
char *last_file = malloc(PATH_MAX_LENGTH + 1);
intfstream_info_t info;
intfstream_t *fd = NULL;
ssize_t last_index = -1;
ssize_t cand_index = -1;
int32_t cand_track = -1;
int32_t track = 0;
size_t largest = 0;
char *tmp_token = (char*)malloc(MAX_TOKEN_LEN);
char *last_file = (char*)malloc(PATH_MAX_LENGTH + 1);
intfstream_t *fd = NULL;
ssize_t last_index = -1;
ssize_t cand_index = -1;
int32_t cand_track = -1;
int32_t track = 0;
size_t largest = 0;
ssize_t volatile file_size = -1;
bool is_data = false;
char *cue_dir = (char*)malloc(PATH_MAX_LENGTH);
cue_dir[0] = '\0';
bool is_data = false;
char *cue_dir = (char*)malloc(PATH_MAX_LENGTH);
cue_dir[0] = '\0';
fill_pathname_basedir(cue_dir, cue_path, PATH_MAX_LENGTH);
info.type = INTFSTREAM_FILE;
fd = (intfstream_t*)intfstream_init(&info);
fd = intfstream_init(&info);
if (!fd)
{
goto error;
}
if (!intfstream_open(fd, cue_path, RFILE_MODE_READ, -1))
{
@ -543,11 +543,11 @@ error:
bool cue_next_file(intfstream_t *fd, const char *cue_path, char *path, size_t max_len)
{
bool rv = false;
char *tmp_token = malloc(MAX_TOKEN_LEN);
bool rv = false;
char *tmp_token = (char*)malloc(MAX_TOKEN_LEN);
ssize_t volatile file_size = -1;
char *cue_dir = (char*)malloc(PATH_MAX_LENGTH);
cue_dir[0] = '\0';
char *cue_dir = (char*)malloc(PATH_MAX_LENGTH);
cue_dir[0] = '\0';
fill_pathname_basedir(cue_dir, cue_path, PATH_MAX_LENGTH);
@ -572,27 +572,27 @@ bool cue_next_file(intfstream_t *fd, const char *cue_path, char *path, size_t ma
int gdi_find_track(const char *gdi_path, bool first, char *track_path, size_t max_len)
{
int rv;
char *tmp_token = malloc(MAX_TOKEN_LEN);
char *last_file = malloc(PATH_MAX_LENGTH + 1);
intfstream_info_t info;
intfstream_t *fd = NULL;
int32_t track = 0;
size_t largest = 0;
int size = -1;
int mode = -1;
char *tmp_token = (char*)malloc(MAX_TOKEN_LEN);
char *last_file = (char*)malloc(PATH_MAX_LENGTH + 1);
intfstream_t *fd = NULL;
int32_t track = 0;
size_t largest = 0;
int size = -1;
int mode = -1;
ssize_t file_size = -1;
char *gdi_dir = (char*)malloc(PATH_MAX_LENGTH);
gdi_dir[0] = '\0';
char *gdi_dir = (char*)malloc(PATH_MAX_LENGTH);
gdi_dir[0] = '\0';
fill_pathname_basedir(gdi_dir, gdi_path, PATH_MAX_LENGTH);
info.type = INTFSTREAM_FILE;
info.type = INTFSTREAM_FILE;
fd = (intfstream_t*)intfstream_init(&info);
fd = intfstream_init(&info);
if (!fd)
{
goto error;
}
if (!intfstream_open(fd, gdi_path, RFILE_MODE_READ, -1))
{
@ -649,18 +649,15 @@ int gdi_find_track(const char *gdi_path, bool first, char *track_path, size_t ma
fill_pathname_join(last_file, gdi_dir, tmp_token, PATH_MAX_LENGTH);
file_size = get_file_size(last_file);
if (file_size < 0)
{
goto error;
}
if (file_size > largest)
if ((unsigned)file_size > largest)
{
strlcpy(track_path, last_file, max_len);
rv = 0;
largest = file_size;
if (first)
{
goto clean;
}
}
}
@ -690,22 +687,20 @@ error:
bool gdi_next_file(intfstream_t *fd, const char *gdi_path, char *path, size_t max_len)
{
bool rv = false;
char *tmp_token = malloc(MAX_TOKEN_LEN);
ssize_t offset = -1;
char *gdi_dir = (char*)malloc(PATH_MAX_LENGTH);
bool rv = false;
char *tmp_token = (char*)malloc(MAX_TOKEN_LEN);
ssize_t offset = -1;
char *gdi_dir = (char*)malloc(PATH_MAX_LENGTH);
gdi_dir[0] = '\0';
tmp_token[0] = '\0';
gdi_dir[0] = '\0';
tmp_token[0] = '\0';
fill_pathname_basedir(gdi_dir, gdi_path, PATH_MAX_LENGTH);
/* Skip initial track count */
offset = intfstream_tell(fd);
if (offset == 0)
{
get_token(fd, tmp_token, MAX_TOKEN_LEN);
}
/* Track number */
get_token(fd, tmp_token, MAX_TOKEN_LEN);