aboutsummaryrefslogtreecommitdiffstats
path: root/src/client.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-28 20:03:03 +0200
committerMax Kellermann <max@duempel.org>2008-08-28 20:03:03 +0200
commitd15e1e09a231f25d5bb8bac2922192560e3ea515 (patch)
tree73ef2f5a1eff020086d6d1b9392ae07073178ce0 /src/client.c
parentc0197c58bae666ddf596d0f585cb419083cd3300 (diff)
downloadmpd-d15e1e09a231f25d5bb8bac2922192560e3ea515.tar.gz
mpd-d15e1e09a231f25d5bb8bac2922192560e3ea515.tar.xz
mpd-d15e1e09a231f25d5bb8bac2922192560e3ea515.zip
client: return early in client_new()
This saves one level of indent.
Diffstat (limited to 'src/client.c')
-rw-r--r--src/client.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/src/client.c b/src/client.c
index e587fd9a4..67417d181 100644
--- a/src/client.c
+++ b/src/client.c
@@ -237,6 +237,7 @@ static void client_close(struct client *client)
void client_new(int fd, const struct sockaddr *addr)
{
unsigned int i;
+ const char *hostname;
for (i = 0; i < client_max_connections
&& clients[i].fd >= 0; i++) /* nothing */ ;
@@ -244,44 +245,44 @@ void client_new(int fd, const struct sockaddr *addr)
if (i == client_max_connections) {
ERROR("Max Connections Reached!\n");
xclose(fd);
- } else {
- const char *hostname;
- switch (addr->sa_family) {
+ return;
+ }
+
+ switch (addr->sa_family) {
#ifdef HAVE_TCP
- case AF_INET:
- hostname = (const char *)inet_ntoa(((const struct sockaddr_in *)
- addr)->sin_addr);
- if (!hostname)
- hostname = "error getting ipv4 address";
- break;
+ case AF_INET:
+ hostname = (const char *)inet_ntoa(((const struct sockaddr_in *)
+ addr)->sin_addr);
+ if (!hostname)
+ hostname = "error getting ipv4 address";
+ break;
#ifdef HAVE_IPV6
- case AF_INET6:
- {
- static char host[INET6_ADDRSTRLEN + 1];
- memset(host, 0, INET6_ADDRSTRLEN + 1);
- if (inet_ntop(AF_INET6, (const void *)
- &(((const struct sockaddr_in6 *)addr)->
- sin6_addr), host,
- INET6_ADDRSTRLEN)) {
- hostname = (const char *)host;
- } else {
- hostname = "error getting ipv6 address";
- }
+ case AF_INET6:
+ {
+ static char host[INET6_ADDRSTRLEN + 1];
+ memset(host, 0, INET6_ADDRSTRLEN + 1);
+ if (inet_ntop(AF_INET6, (const void *)
+ &(((const struct sockaddr_in6 *)addr)->
+ sin6_addr), host,
+ INET6_ADDRSTRLEN)) {
+ hostname = (const char *)host;
+ } else {
+ hostname = "error getting ipv6 address";
}
- break;
+ }
+ break;
#endif
#endif /* HAVE_TCP */
#ifdef HAVE_UN
- case AF_UNIX:
- hostname = "local connection";
- break;
+ case AF_UNIX:
+ hostname = "local connection";
+ break;
#endif /* HAVE_UN */
- default:
- hostname = "unknown";
- }
- SECURE("client %i: opened from %s\n", i, hostname);
- client_init(&(clients[i]), fd);
+ default:
+ hostname = "unknown";
}
+ SECURE("client %i: opened from %s\n", i, hostname);
+ client_init(&(clients[i]), fd);
}
static int client_process_line(struct client *client)