Get rid of a lot of implicit conversions

This commit is contained in:
Twinaphex 2018-04-09 15:56:45 +02:00
parent 91ba0765e6
commit 08a54e45f2
23 changed files with 84 additions and 85 deletions

View File

@ -213,7 +213,7 @@ bool compute_audio_buffer_statistics(audio_statistics_t *stats)
if (!stats || samples < 3)
return false;
stats->samples = audio_driver_free_samples_count;
stats->samples = (unsigned)audio_driver_free_samples_count;
#ifdef WARPUP
/* uint64 to double not implemented, fair chance

View File

@ -1339,7 +1339,7 @@ static int cheevos_new_lboard(cheevos_readud_t *ud)
if (!lboard)
return -1;
lboard->id = strtol(ud->id.string, NULL, 10);
lboard->id = (unsigned)strtol(ud->id.string, NULL, 10);
lboard->format = cheevos_parse_format(&ud->format);
lboard->title = cheevos_dupstr(&ud->title);
lboard->description = cheevos_dupstr(&ud->desc);
@ -3468,7 +3468,7 @@ found:
if ((void*)coro->json)
free((void*)coro->json);
RARCH_LOG("[CHEEVOS]: got game id %s.\n", gameid);
coro->gameid = strtol(gameid, NULL, 10);
coro->gameid = (unsigned)strtol(gameid, NULL, 10);
CORO_RET();
}
@ -3733,7 +3733,7 @@ found:
coro->json[length] = 0;
}
coro->k = length;
coro->k = (unsigned)length;
net_http_delete(coro->http);
net_http_connection_free(coro->conn);
CORO_RET();

View File

@ -3278,7 +3278,7 @@ static stb_vorbis * vorbis_alloc(stb_vorbis *f)
unsigned int stb_vorbis_get_file_offset(stb_vorbis *f)
{
return f->stream - f->stream_start;
return (unsigned int)(f->stream - f->stream_start);
}
#ifndef STB_VORBIS_NO_PULLDATA_API

View File

@ -747,7 +747,7 @@ static void gl_render_osd_background(
float *verts = (float*)malloc(2 * vertices_total * sizeof(float));
settings_t *settings = config_get_ptr();
int msg_width =
font_driver_get_message_width(NULL, msg, strlen(msg), 1.0f);
font_driver_get_message_width(NULL, msg, (unsigned)strlen(msg), 1.0f);
/* shader driver expects vertex coords as 0..1 */
float x = video_info->font_msg_pos_x;

View File

@ -1486,9 +1486,9 @@ static bool gl_glsl_set_mvp(void *data, void *shader_data, const void *mat_data)
#define gl_glsl_set_coord_array(attribs, coord1, coord2, coords, size, multiplier) \
unsigned y; \
attribs[attribs_size].loc = coord1; \
attribs[attribs_size].size = multiplier; \
attribs[attribs_size].offset = size * sizeof(GLfloat); \
attribs[attribs_size].loc = (GLint)coord1; \
attribs[attribs_size].size = (GLsizei)multiplier; \
attribs[attribs_size].offset = (GLsizei)(size * sizeof(GLfloat)); \
for (y = 0; y < (multiplier * coords->vertices); y++) \
buffer[y + size] = coord2[y]; \
size += multiplier * coords->vertices; \

View File

@ -667,7 +667,7 @@ static void audio_mixer_mix_ogg(float* buffer, size_t num_frames,
int i;
struct resampler_data info;
float temp_buffer[AUDIO_MIXER_TEMP_OGG_BUFFER];
unsigned buf_free = num_frames * 2;
unsigned buf_free = (unsigned)(num_frames * 2);
unsigned temp_samples = 0;
float* pcm = NULL;
@ -740,7 +740,7 @@ static void audio_mixer_mix_mod(float* buffer, size_t num_frames,
float samplef = 0.0f;
int samplei = 0;
unsigned temp_samples = 0;
unsigned buf_free = num_frames * 2;
unsigned buf_free = (unsigned)(num_frames * 2);
int* pcm = NULL;
if (voice->types.mod.position == voice->types.mod.samples)

View File

@ -320,14 +320,14 @@ int filestream_putc(RFILE *stream, int c)
int filestream_vprintf(RFILE *stream, const char* format, va_list args)
{
static char buffer[8 * 1024];
int num_chars = vsprintf(buffer, format, args);
int64_t num_chars = vsprintf(buffer, format, args);
if (num_chars < 0)
return -1;
else if (num_chars == 0)
return 0;
return filestream_write(stream, buffer, num_chars);
return (int)filestream_write(stream, buffer, num_chars);
}
int filestream_printf(RFILE *stream, const char* format, ...)

View File

@ -93,7 +93,7 @@ int rfseek(RFILE* stream, long offset, int origin)
break;
}
return filestream_seek(stream, offset, seek_position);
return (int)filestream_seek(stream, (ssize_t)offset, seek_position);
}
size_t rfread(void* buffer,

View File

@ -435,7 +435,7 @@ intfstream_t *intfstream_open_memory(void *data,
info.type = INTFSTREAM_MEMORY;
info.memory.buf.data = (uint8_t*)data;
info.memory.buf.size = size;
info.memory.buf.size = (unsigned)size;
info.memory.writable = false;
fd = (intfstream_t*)intfstream_init(&info);

View File

@ -169,7 +169,7 @@ char *word_wrap(char* buffer, const char *string, int line_width, bool unicode)
}
character = utf8skip(&string[i], 1);
char_len = character - &string[i];
char_len = (unsigned)(character - &string[i]);
if (!unicode)
counter += char_len - 1;

View File

@ -631,7 +631,7 @@ static void materialui_render_messagebox(materialui_handle_t *mui,
{
longest = len;
longest_width = font_driver_get_message_width(
mui->font, msg, strlen(msg), 1);
mui->font, msg, (unsigned)strlen(msg), 1);
}
}
@ -1630,7 +1630,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
);
}
ticker_limit = usable_width / mui->glyph_width;
ticker_limit = (unsigned)(usable_width / mui->glyph_width);
ticker.s = title_buf;
ticker.len = ticker_limit;

View File

@ -468,7 +468,7 @@ static void xmb_free_node(xmb_node_t *node)
*/
static void xmb_free_list_nodes(file_list_t *list, bool actiondata)
{
unsigned i, size = file_list_get_size(list);
unsigned i, size = (unsigned)file_list_get_size(list);
for (i = 0; i < size; ++i)
{
@ -935,7 +935,7 @@ static void xmb_render_messagebox_internal(
{
longest = len;
longest_width = font_driver_get_message_width(
xmb->font, msg, strlen(msg), 1);
xmb->font, msg, (unsigned)strlen(msg), 1);
}
}
@ -1633,17 +1633,16 @@ static void xmb_push_animations(xmb_node_t *node,
static void xmb_list_switch_old(xmb_handle_t *xmb,
file_list_t *list, int dir, size_t current)
{
unsigned i, first, last, height;
size_t end = file_list_get_size(list);
float ix = -xmb->icon_spacing_horizontal * dir;
float ia = 0;
first = 0;
last = end > 0 ? end - 1 : 0;
unsigned i, height;
size_t end = file_list_get_size(list);
float ix = -xmb->icon_spacing_horizontal * dir;
float ia = 0;
unsigned first = 0;
unsigned last = (unsigned)(end > 0 ? end - 1 : 0);
video_driver_get_size(NULL, &height);
xmb_calculate_visible_range(xmb, height, end,
current, &first, &last);
(unsigned)current, &first, &last);
for (i = 0; i < end; i++)
{
@ -1714,10 +1713,10 @@ static void xmb_list_switch_new(xmb_handle_t *xmb,
end = file_list_get_size(list);
first = 0;
last = end > 0 ? end - 1 : 0;
last = (unsigned)(end > 0 ? end - 1 : 0);
video_driver_get_size(NULL, &height);
xmb_calculate_visible_range(xmb, height, end, current, &first, &last);
xmb_calculate_visible_range(xmb, height, end, (unsigned)current, &first, &last);
for (i = 0; i < end; i++)
{
@ -2445,7 +2444,7 @@ static void xmb_calculate_visible_range(const xmb_handle_t *xmb,
float base_y = xmb->margins_screen_top;
*first = 0;
*last = list_size ? list_size - 1 : 0;
*last = (unsigned)(list_size ? list_size - 1 : 0);
if (current)
{
@ -2782,10 +2781,10 @@ static void xmb_draw_items(
i = 0;
}
first = i;
last = end - 1;
first = (unsigned)i;
last = (unsigned)(end - 1);
xmb_calculate_visible_range(xmb, height, end, current, &first, &last);
xmb_calculate_visible_range(xmb, height, end, (unsigned)current, &first, &last);
menu_display_blend_begin(video_info);
@ -2834,18 +2833,18 @@ static void xmb_render(void *data, bool is_idle)
if (pointer_enable || mouse_enable)
{
unsigned height;
size_t selection = menu_navigation_get_selection();
int16_t pointer_y = menu_input_pointer_state(MENU_POINTER_Y_AXIS);
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS)
+ (xmb->cursor_size/2);
unsigned first = 0, last = end;
unsigned height;
video_driver_get_size(NULL, &height);
if (height)
xmb_calculate_visible_range(xmb, height,
end, selection, &first, &last);
end, (unsigned)selection, &first, &last);
for (i = first; i <= last; i++)
{
@ -4645,7 +4644,7 @@ static void xmb_list_cache(void *data, enum menu_list_type type, unsigned action
xmb->selection_ptr_old = selection;
xmb_calculate_visible_range(xmb, height, selection_buf->size,
xmb->selection_ptr_old, &first, &last);
(unsigned)xmb->selection_ptr_old, &first, &last);
xmb_list_deep_copy(selection_buf, xmb->selection_buf_old, first, last);

View File

@ -290,7 +290,7 @@ static void bsv_movie_frame_rewind(bsv_movie_t *handle)
{
/* If we're at the beginning... */
handle->frame_ptr = 0;
intfstream_seek(handle->file, handle->min_file_pos, SEEK_SET);
intfstream_seek(handle->file, (int)handle->min_file_pos, SEEK_SET);
}
else
{
@ -303,7 +303,7 @@ static void bsv_movie_frame_rewind(bsv_movie_t *handle)
handle->frame_ptr = (handle->frame_ptr -
(handle->first_rewind ? 1 : 2)) & handle->frame_mask;
intfstream_seek(handle->file,
handle->frame_pos[handle->frame_ptr], SEEK_SET);
(int)handle->frame_pos[handle->frame_ptr], SEEK_SET);
}
if (intfstream_tell(handle->file) <= (long)handle->min_file_pos)
@ -327,7 +327,7 @@ static void bsv_movie_frame_rewind(bsv_movie_t *handle)
intfstream_write(handle->file, handle->state, handle->state_size);
}
else
intfstream_seek(handle->file, handle->min_file_pos, SEEK_SET);
intfstream_seek(handle->file, (int)handle->min_file_pos, SEEK_SET);
}
}

View File

@ -155,10 +155,10 @@ netplay_input_state_t netplay_input_state_for(netplay_input_state_t *list,
ret = (netplay_input_state_t)calloc(1, sizeof(struct netplay_input_state) + (size-1) * sizeof(uint32_t));
if (!ret)
return NULL;
*list = ret;
*list = ret;
ret->client_num = client_num;
ret->used = true;
ret->size = size;
ret->used = true;
ret->size = (uint32_t)size;
return ret;
}

View File

@ -168,7 +168,7 @@ bool netplay_discovery_driver_ctl(enum rarch_netplay_discovery_ctl_state state,
NETPLAY_HOST_STR_LEN);
/* And send it off */
ret = sendto(lan_ad_client_fd, (const char *) &ad_packet_buffer,
ret = (int)sendto(lan_ad_client_fd, (const char *) &ad_packet_buffer,
sizeof(struct ad_packet), 0, addr->ai_addr, addr->ai_addrlen);
if (ret < (ssize_t) (2*sizeof(uint32_t)))
RARCH_WARN("[discovery] Failed to send netplay discovery query (error: %d)\n", errno);
@ -262,8 +262,7 @@ bool netplay_lan_ad_server(netplay_t *netplay)
/* Somebody queried, so check that it's valid */
addr_size = sizeof(their_addr);
ret = recvfrom(lan_ad_server_fd, (char*)&ad_packet_buffer,
ret = (int)recvfrom(lan_ad_server_fd, (char*)&ad_packet_buffer,
sizeof(struct ad_packet), 0, &their_addr, &addr_size);
if (ret >= (ssize_t) (2 * sizeof(uint32_t)))
{

View File

@ -564,8 +564,8 @@ bool netplay_handshake_sync(netplay_t *netplay,
autosave_unlock();
/* Send basic sync info */
cmd[0] = htonl(NETPLAY_CMD_SYNC);
cmd[1] = htonl(2*sizeof(uint32_t)
cmd[0] = htonl(NETPLAY_CMD_SYNC);
cmd[1] = htonl(2*sizeof(uint32_t)
/* Controller devices */
+ MAX_INPUT_DEVICES*sizeof(uint32_t)
@ -580,11 +580,13 @@ bool netplay_handshake_sync(netplay_t *netplay,
/* And finally, sram */
+ mem_info.size);
cmd[2] = htonl(netplay->self_frame_count);
client_num = connection - netplay->connections + 1;
cmd[2] = htonl(netplay->self_frame_count);
client_num = (uint32_t)(connection - netplay->connections + 1);
if (netplay->local_paused || netplay->remote_paused)
client_num |= NETPLAY_CMD_SYNC_BIT_PAUSED;
cmd[3] = htonl(client_num);
cmd[3] = htonl(client_num);
if (!netplay_send(&connection->send_packet_buffer, connection->fd, cmd,
sizeof(cmd)))

View File

@ -142,7 +142,7 @@ void netplay_hangup(netplay_t *netplay, struct netplay_connection *connection)
}
else
{
uint32_t client_num = connection - netplay->connections + 1;
uint32_t client_num = (uint32_t)(connection - netplay->connections + 1);
/* Mark the player for removal */
if (connection->mode == NETPLAY_CONNECTION_PLAYING ||
@ -177,22 +177,23 @@ void netplay_hangup(netplay_t *netplay, struct netplay_connection *connection)
*/
void netplay_delayed_state_change(netplay_t *netplay)
{
struct netplay_connection *connection;
size_t i;
unsigned i;
for (i = 0; i < netplay->connections_size; i++)
{
uint32_t client_num = i+1;
connection = &netplay->connections[i];
uint32_t client_num = (uint32_t)(i + 1);
struct netplay_connection *connection = &netplay->connections[i];
if ((connection->active || connection->mode == NETPLAY_CONNECTION_DELAYED_DISCONNECT) &&
connection->delay_frame &&
connection->delay_frame <= netplay->self_frame_count)
{
/* Something was delayed! Prepare the MODE command */
uint32_t payload[15] = {0};
payload[0] = htonl(connection->delay_frame);
payload[1] = htonl(client_num);
payload[2] = htonl(0);
payload[0] = htonl(connection->delay_frame);
payload[1] = htonl(client_num);
payload[2] = htonl(0);
memcpy(payload + 3, netplay->device_share_modes, sizeof(netplay->device_share_modes));
strncpy((char *) (payload + 7), connection->nick, NETPLAY_NICK_LEN);
@ -294,7 +295,7 @@ bool netplay_send_cur_input(netplay_t *netplay,
if (netplay->is_server)
{
to_client = connection - netplay->connections + 1;
to_client = (uint32_t)(connection - netplay->connections + 1);
/* Send the other players' input data (FIXME: This involves an
* unacceptable amount of recalculating) */
@ -302,6 +303,7 @@ bool netplay_send_cur_input(netplay_t *netplay,
{
if (from_client == to_client)
continue;
if ((netplay->connected_players & (1<<from_client)))
{
if (dframe->have_real[from_client])
@ -957,7 +959,7 @@ static bool netplay_get_cmd(netplay_t *netplay,
RARCH_ERR("Netplay input from non-participating player.\n");
return netplay_cmd_nak(netplay, connection);
}
client_num = connection - netplay->connections + 1;
client_num = (uint32_t)(connection - netplay->connections + 1);
}
if (client_num > MAX_CLIENTS)
@ -1129,7 +1131,7 @@ static bool netplay_get_cmd(netplay_t *netplay,
return netplay_cmd_nak(netplay, connection);
}
client_num = connection - netplay->connections + 1;
client_num = (uint32_t)(connection - netplay->connections + 1);
handle_play_spectate(netplay, client_num, connection, cmd, 0, NULL);
break;
@ -1180,7 +1182,7 @@ static bool netplay_get_cmd(netplay_t *netplay,
return netplay_cmd_nak(netplay, connection);
}
client_num = connection - netplay->connections + 1;
client_num = (unsigned)(connection - netplay->connections + 1);
handle_play_spectate(netplay, client_num, connection, cmd, cmd_size, payload);
break;
@ -1552,12 +1554,12 @@ static bool netplay_get_cmd(netplay_t *netplay,
uint32_t frame;
uint32_t isize;
uint32_t rd, wn;
uint32_t client, client_num;
uint32_t client;
uint32_t load_frame_count;
size_t load_ptr;
struct compression_transcoder *ctrans;
client_num = connection - netplay->connections + 1;
struct compression_transcoder *ctrans = NULL;
uint32_t client_num = (uint32_t)
(connection - netplay->connections + 1);
/* Make sure we're ready for it */
if (netplay->quirks & NETPLAY_QUIRK_INITIALIZATION)
@ -1926,8 +1928,8 @@ void netplay_handle_slaves(netplay_t *netplay)
if (connection->active &&
connection->mode == NETPLAY_CONNECTION_SLAVE)
{
uint32_t client_num = i + 1;
uint32_t devices, device;
uint32_t client_num = (uint32_t)(i + 1);
/* This is a slave connection. First, should we do anything at all? If
* we've already "read" this data, then we can just ignore it */

View File

@ -947,12 +947,14 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
* clients ahead of us stall */
for (i = 0; i < netplay->connections_size; i++)
{
struct netplay_connection *connection = &netplay->connections[i];
uint32_t client_num;
struct netplay_connection *connection = &netplay->connections[i];
if (!connection->active ||
connection->mode != NETPLAY_CONNECTION_PLAYING)
continue;
client_num = i + 1;
client_num = (uint32_t)(i + 1);
/* Are they ahead? */
if (netplay->self_frame_count + 3 < netplay->read_frame_count[client_num])

View File

@ -404,7 +404,7 @@ static bool runahead_load_state_secondary(void)
set_fast_savestate();
okay = secondary_core_deserialize(
serialize_info->data_const, serialize_info->size);
serialize_info->data_const, (int)serialize_info->size);
unset_fast_savestate();
if (!okay)

View File

@ -146,7 +146,7 @@ bool write_file_with_random_name(char **tempDllPath,
unsigned int number_value= (unsigned int)time_value;
int number = 0;
char *ext = strcpy_alloc_force(path_get_extension(*tempDllPath));
int ext_len = strlen(ext);
int ext_len = (int)strlen(ext);
if (ext_len > 0)
{
@ -259,7 +259,7 @@ bool secondary_core_create(void)
{
device = port_map[port];
if (device >= 0)
secondary_core.retro_set_controller_port_device(port, device);
secondary_core.retro_set_controller_port_device((unsigned)port, (unsigned)device);
}
clear_controller_port_map();
}
@ -335,9 +335,9 @@ void secondary_core_destroy(void)
void remember_controller_port_device(long port, long device)
{
if (port >= 0 && port < 16)
port_map[port] = device;
port_map[port] = (int)device;
if (secondary_module && secondary_core.retro_set_controller_port_device)
secondary_core.retro_set_controller_port_device(port, device);
secondary_core.retro_set_controller_port_device((unsigned)port, (unsigned)device);
}
void clear_controller_port_map(void)

View File

@ -73,7 +73,7 @@ static int cb_nbio_audio_mixer_load(void *data, size_t len)
image->buffer = buffer;
image->buffer->buf = ptr;
image->buffer->bufsize = len;
image->buffer->bufsize = (unsigned)len;
image->copy_data_over = true;
nbio->is_finished = true;

View File

@ -225,7 +225,7 @@ static bool intfstream_file_get_serial(const char *name,
if (offset != 0 || size < (size_t) file_size)
{
if (intfstream_seek(fd, offset, SEEK_SET) == -1)
if (intfstream_seek(fd, (int)offset, SEEK_SET) == -1)
goto error;
data = (uint8_t*)malloc(size);
@ -377,7 +377,7 @@ static bool intfstream_file_get_crc(const char *name,
if (offset != 0 || size < (size_t) file_size)
{
if (intfstream_seek(fd, offset, SEEK_SET) == -1)
if (intfstream_seek(fd, (int)offset, SEEK_SET) == -1)
goto error;
data = (uint8_t*)malloc(size);

View File

@ -121,17 +121,12 @@ void retro_main_log_file_deinit(void)
#if !defined(HAVE_LOGGER)
void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
{
#if TARGET_OS_IPHONE
static int asl_initialized = 0;
#if !TARGET_IPHONE_SIMULATOR
static aslclient asl_client;
#endif
#endif
#if TARGET_OS_IPHONE
#if TARGET_IPHONE_SIMULATOR
vprintf(fmt, ap);
#else
static aslclient asl_client;ß
static int asl_initialized = 0;
if (!asl_initialized)
{
asl_client = asl_open(