Prevent some implicit memsets

This commit is contained in:
twinaphex 2016-10-21 19:39:51 +02:00
parent 7b7a0e20cc
commit 42053a82e1
3 changed files with 19 additions and 11 deletions

View File

@ -121,12 +121,14 @@ end:
static bool init_tcp_socket(netplay_t *netplay, const char *server,
uint16_t port, bool spectate)
{
char port_buf[16] = {0};
char port_buf[16];
bool ret = false;
const struct addrinfo *tmp_info = NULL;
struct addrinfo *res = NULL;
struct addrinfo hints = {0};
port_buf[0] = '\0';
hints.ai_socktype = SOCK_STREAM;
if (!server)
hints.ai_flags = AI_PASSIVE;
@ -943,7 +945,9 @@ void netplay_log_connection(const struct sockaddr_storage *their_addr,
const char *str = NULL;
char buf_v4[INET_ADDRSTRLEN] = {0};
char buf_v6[INET6_ADDRSTRLEN] = {0};
char msg[512] = {0};
char msg[512];
msg[0] = '\0';
u.storage = their_addr;
@ -1002,7 +1006,9 @@ void netplay_log_connection(const struct sockaddr_storage *their_addr,
void netplay_log_connection(const struct sockaddr_storage *their_addr,
unsigned slot, const char *nick)
{
char msg[512] = {0};
char msg[512];
msg[0] = '\0';
snprintf(msg, sizeof(msg), "Got connection from: \"%s\"",
nick);
@ -1473,10 +1479,10 @@ void deinit_netplay(void)
bool init_netplay(bool is_spectate, const char *server, unsigned port)
{
struct retro_callbacks cbs = {0};
settings_t *settings = config_get_ptr();
struct retro_callbacks cbs = {0};
settings_t *settings = config_get_ptr();
uint64_t serialization_quirks = 0;
uint64_t quirks = 0;
uint64_t quirks = 0;
if (!netplay_enabled)
return false;

View File

@ -159,15 +159,17 @@ static bool netplay_endian_mismatch(uint32_t pma, uint32_t pmb)
bool netplay_handshake(netplay_t *netplay)
{
size_t i;
uint32_t local_pmagic, remote_pmagic;
unsigned sram_size, remote_sram_size;
retro_ctx_memory_info_t mem_info;
char msg[512] = {0};
char msg[512];
uint32_t *content_crc_ptr = NULL;
void *sram = NULL;
uint32_t header[4] = {0};
size_t i;
uint32_t local_pmagic, remote_pmagic;
bool is_server = netplay->is_server;
bool is_server = netplay->is_server;
msg[0] = '\0';
mem_info.id = RETRO_MEMORY_SAVE_RAM;

View File

@ -39,12 +39,12 @@ static bool netplay_spectate_pre_frame(netplay_t *netplay)
if (netplay_is_server(netplay))
{
fd_set fds;
struct timeval tmp_tv = {0};
int new_fd, idx, i;
struct sockaddr_storage their_addr;
socklen_t addr_size;
retro_ctx_serialize_info_t serial_info;
uint32_t header[3];
struct timeval tmp_tv = {0};
netplay->can_poll = true;
input_poll_net();