Merge pull request #9596 from orbea/networking

Remove redundant conditionals.
This commit is contained in:
Twinaphex 2019-10-15 18:36:38 +02:00 committed by GitHub
commit 50fbf04df5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 13 deletions

View File

@ -2107,20 +2107,20 @@ struct command
char stdin_buf[STDIN_BUF_SIZE]; char stdin_buf[STDIN_BUF_SIZE];
size_t stdin_buf_ptr; size_t stdin_buf_ptr;
#endif #endif
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD) #ifdef HAVE_NETWORK_CMD
int net_fd; int net_fd;
#endif #endif
}; };
#if defined(HAVE_COMMAND) #if defined(HAVE_COMMAND)
static enum cmd_source_t lastcmd_source; static enum cmd_source_t lastcmd_source;
#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETWORKING) #ifdef HAVE_NETWORK_CMD
static int lastcmd_net_fd; static int lastcmd_net_fd;
static struct sockaddr_storage lastcmd_net_source; static struct sockaddr_storage lastcmd_net_source;
static socklen_t lastcmd_net_source_len; static socklen_t lastcmd_net_source_len;
#endif #endif
#if defined(HAVE_CHEEVOS) && (defined(HAVE_STDIN_CMD) || defined(HAVE_NETWORK_CMD) && defined(HAVE_NETWORKING)) #if defined(HAVE_CHEEVOS) && (defined(HAVE_STDIN_CMD) || defined(HAVE_NETWORK_CMD))
static void command_reply(const char * data, size_t len) static void command_reply(const char * data, size_t len)
{ {
switch (lastcmd_source) switch (lastcmd_source)
@ -2131,7 +2131,7 @@ static void command_reply(const char * data, size_t len)
#endif #endif
break; break;
case CMD_NETWORK: case CMD_NETWORK:
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD) #ifdef HAVE_NETWORK_CMD
sendto(lastcmd_net_fd, data, len, 0, sendto(lastcmd_net_fd, data, len, 0,
(struct sockaddr*)&lastcmd_net_source, lastcmd_net_source_len); (struct sockaddr*)&lastcmd_net_source, lastcmd_net_source_len);
#endif #endif
@ -2148,7 +2148,7 @@ static bool command_version(const char* arg)
char reply[256] = {0}; char reply[256] = {0};
snprintf(reply, sizeof(reply), "%s\n", PACKAGE_VERSION); snprintf(reply, sizeof(reply), "%s\n", PACKAGE_VERSION);
#if defined(HAVE_CHEEVOS) && (defined(HAVE_STDIN_CMD) || defined(HAVE_NETWORK_CMD) && defined(HAVE_NETWORKING)) #if defined(HAVE_CHEEVOS) && (defined(HAVE_STDIN_CMD) || defined(HAVE_NETWORK_CMD))
command_reply(reply, strlen(reply)); command_reply(reply, strlen(reply));
#endif #endif
@ -2380,7 +2380,7 @@ static bool command_write_ram(const char *arg)
} }
#endif #endif
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD) #ifdef HAVE_NETWORK_CMD
static bool command_get_arg(const char *tok, static bool command_get_arg(const char *tok,
const char **arg, unsigned *index) const char **arg, unsigned *index)
{ {
@ -2605,7 +2605,7 @@ static void command_network_poll(command_t *handle)
static bool command_free(command_t *handle) static bool command_free(command_t *handle)
{ {
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD) #ifdef HAVE_NETWORK_CMD
if (handle && handle->net_fd >= 0) if (handle && handle->net_fd >= 0)
socket_close(handle->net_fd); socket_close(handle->net_fd);
#endif #endif
@ -2678,7 +2678,7 @@ static bool command_network_new(
bool network_enable, bool network_enable,
uint16_t port) uint16_t port)
{ {
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD) #ifdef HAVE_NETWORK_CMD
handle->net_fd = -1; handle->net_fd = -1;
if (network_enable && !command_network_init(handle, port)) if (network_enable && !command_network_init(handle, port))
goto error; goto error;
@ -2692,7 +2692,7 @@ static bool command_network_new(
return true; return true;
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD) || defined(HAVE_STDIN_CMD) #if defined(HAVE_NETWORK_CMD) || defined(HAVE_STDIN_CMD)
error: error:
command_free(handle); command_free(handle);
return false; return false;
@ -11894,7 +11894,7 @@ static void input_driver_poll(void)
if (input_driver_command) if (input_driver_command)
{ {
memset(input_driver_command->state, 0, sizeof(input_driver_command->state)); memset(input_driver_command->state, 0, sizeof(input_driver_command->state));
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORK_CMD) && defined(HAVE_COMMAND) #if defined(HAVE_NETWORK_CMD) && defined(HAVE_COMMAND)
command_network_poll(input_driver_command); command_network_poll(input_driver_command);
#endif #endif
@ -22350,7 +22350,7 @@ static void retroarch_print_help(const char *arg0)
strlcat(buf, " (requires a very fast network).\n", sizeof(buf)); strlcat(buf, " (requires a very fast network).\n", sizeof(buf));
strlcat(buf, " --check-frames=NUMBER\n" strlcat(buf, " --check-frames=NUMBER\n"
" Check frames when using netplay.\n", sizeof(buf)); " Check frames when using netplay.\n", sizeof(buf));
#if defined(HAVE_NETWORK_CMD) #ifdef HAVE_NETWORK_CMD
strlcat(buf, " --command Sends a command over UDP to an already " strlcat(buf, " --command Sends a command over UDP to an already "
"running program process.\n", sizeof(buf)); "running program process.\n", sizeof(buf));
strlcat(buf, " Available commands are listed if command is invalid.\n", sizeof(buf)); strlcat(buf, " Available commands are listed if command is invalid.\n", sizeof(buf));
@ -22446,7 +22446,7 @@ static void retroarch_parse_input_and_config(int argc, char *argv[])
{ "stateless", 0, NULL, RA_OPT_STATELESS }, { "stateless", 0, NULL, RA_OPT_STATELESS },
{ "check-frames", 1, NULL, RA_OPT_CHECK_FRAMES }, { "check-frames", 1, NULL, RA_OPT_CHECK_FRAMES },
{ "port", 1, NULL, RA_OPT_PORT }, { "port", 1, NULL, RA_OPT_PORT },
#if defined(HAVE_NETWORK_CMD) #ifdef HAVE_NETWORK_CMD
{ "command", 1, NULL, RA_OPT_COMMAND }, { "command", 1, NULL, RA_OPT_COMMAND },
#endif #endif
#endif #endif
@ -22850,7 +22850,7 @@ static void retroarch_parse_input_and_config(int argc, char *argv[])
} }
break; break;
#if defined(HAVE_NETWORK_CMD) #ifdef HAVE_NETWORK_CMD
case RA_OPT_COMMAND: case RA_OPT_COMMAND:
#ifdef HAVE_COMMAND #ifdef HAVE_COMMAND
if (command_network_send((const char*)optarg)) if (command_network_send((const char*)optarg))