summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.c56
-rw-r--r--igmp.c8
-rw-r--r--rcon.c10
-rw-r--r--server.c11
4 files changed, 43 insertions, 42 deletions
diff --git a/config.c b/config.c
index bb107ef..3a59b77 100644
--- a/config.c
+++ b/config.c
@@ -80,12 +80,12 @@ strtosockaddrs(const char *str, struct list_head *list)
str++;
tmp = strchr(str, ']');
if (!tmp)
- goto out;
+ goto error;
*tmp = '\0';
saddr = zmalloc(sizeof(*saddr));
if (!saddr)
- goto out;
+ goto error;
/* early list_add to make sure saddr is free():d on error */
list_add(&saddr->list, list);
@@ -93,15 +93,15 @@ strtosockaddrs(const char *str, struct list_head *list)
if (!strcmp(str, "*"))
saddr->in6.sin6_addr = in6addr_any;
else if (inet_pton(AF_INET6, str, &saddr->in6.sin6_addr) <= 0)
- goto out;
+ goto error;
tmp++;
if (*tmp != ':')
- goto out;
+ goto error;
tmp++;
if (strtou16_strict(tmp, &port) < 0)
- goto out;
+ goto error;
saddr_set_ipv6(saddr, NULL, htons(port));
@@ -111,15 +111,15 @@ strtosockaddrs(const char *str, struct list_head *list)
str++;
if (*str != ':')
- goto out;
+ goto error;
str++;
if (strtou16_strict(str, &port) < 0)
- goto out;
+ goto error;
saddr = zmalloc(sizeof(*saddr));
if (!saddr)
- goto out;
+ goto error;
saddr_set_ipv4(saddr, INADDR_ANY, htons(port));
list_add(&saddr->list, list);
@@ -131,11 +131,11 @@ strtosockaddrs(const char *str, struct list_head *list)
*tmp = '\0';
tmp++;
if (strtou16_strict(tmp, &port) < 0)
- goto out;
+ goto error;
saddr = zmalloc(sizeof(*saddr));
if (!saddr)
- goto out;
+ goto error;
if (inet_pton(AF_INET, str, &saddr->in4.sin_addr) > 0) {
debug(DBG_CFG, "got an IPv4:port (%s)\n", str);
@@ -158,7 +158,7 @@ strtosockaddrs(const char *str, struct list_head *list)
r = getaddrinfo(str, tmp, &hints, &results);
if (r != 0) {
error("getaddrinfo(%s): %s\n", str, gai_strerror(r));
- goto out;
+ goto error;
}
debug(DBG_CFG, "got a hostname:port (%s)\n", str);
@@ -166,7 +166,7 @@ strtosockaddrs(const char *str, struct list_head *list)
saddr = zmalloc(sizeof(*saddr));
if (!saddr) {
freeaddrinfo(results);
- goto out;
+ goto error;
}
switch (ai->ai_family) {
@@ -190,7 +190,7 @@ strtosockaddrs(const char *str, struct list_head *list)
error("getaddrinfo(%s): unknown address family (%i)\n",
str, ai->ai_family);
xfree(saddr);
- continue;
+ break;
}
}
@@ -202,14 +202,14 @@ strtosockaddrs(const char *str, struct list_head *list)
saddr = zmalloc(sizeof(*saddr));
if (!saddr)
- goto out;
+ goto error;
saddr_set_ipv6(saddr, &in6addr_any, htons(port));
list_add(&saddr->list, list);
saddr = zmalloc(sizeof(*saddr));
if (!saddr)
- goto out;
+ goto error;
saddr_set_ipv4(saddr, INADDR_ANY, htons(port));
list_add(&saddr->list, list);
@@ -217,7 +217,7 @@ strtosockaddrs(const char *str, struct list_head *list)
} else {
/* Unknown */
error("unable to parse address: %s\n", str);
- goto out;
+ goto error;
}
success:
@@ -235,7 +235,7 @@ success:
return true;
-out:
+error:
if (!list_empty(list)) {
struct saddr *tmp;
@@ -247,7 +247,7 @@ out:
return false;
}
-/* Returns true if theres data left to parse in buf */
+/* Returns true if there's data left to parse in buf */
bool
config_parse_line(struct cfg *cfg, const char *filename, char **buf,
struct cfg_key_value_map *kvmap, int *rkey,
@@ -271,14 +271,14 @@ config_parse_line(struct cfg *cfg, const char *filename, char **buf,
tmp++;
if (*tmp == '\0')
- goto out;
+ goto error;
key = tmp;
while (*tmp != '\0' && !isspace(*tmp))
tmp++;
if (*tmp == '\0')
- goto out;
+ goto error;
*tmp = '\0';
tmp++;
@@ -287,14 +287,14 @@ config_parse_line(struct cfg *cfg, const char *filename, char **buf,
tmp++;
if (*tmp != '=')
- goto out;
+ goto error;
tmp++;
while (isspace(*tmp))
tmp++;
if (*tmp == '\0')
- goto out;
+ goto error;
for (i = 0; kvmap[i].key_name; i++) {
if (strcmp(kvmap[i].key_name, key))
@@ -310,17 +310,17 @@ config_parse_line(struct cfg *cfg, const char *filename, char **buf,
uint16_t v;
if (strtou16_strict(tmp, &v) < 0)
- goto out;
+ goto error;
rvalue->uint16 = v;
break;
}
case CFG_VAL_TYPE_ADDRS: {
if (!strtosockaddrs(tmp, &rvalue->saddrs))
- goto out;
+ goto error;
if (list_empty(&rvalue->saddrs)) {
error("empty address list\n");
- goto out;
+ goto error;
}
break;
}
@@ -332,14 +332,14 @@ config_parse_line(struct cfg *cfg, const char *filename, char **buf,
rvalue->boolean = false;
else {
error("invalid boolean value (%s)\n", tmp);
- goto out;
+ goto error;
}
break;
case CFG_VAL_TYPE_INVALID:
/* fall through */
default:
- goto out;
+ goto error;
}
*rkey = kvmap[i].key_value;
@@ -347,7 +347,7 @@ config_parse_line(struct cfg *cfg, const char *filename, char **buf,
return true;
}
-out:
+error:
/* FIXME: the line is already mangled here, a line number would be nice */
error("%s: invalid config line: %s\n", filename, line);
*rkey = 0;
diff --git a/igmp.c b/igmp.c
index 71bf3df..26fe56f 100644
--- a/igmp.c
+++ b/igmp.c
@@ -512,7 +512,7 @@ igmp_init(struct cfg *cfg)
error("permission denied\n");
else
error("%m\n");
- goto out_free;
+ goto error_free;
}
if (setsockopt(sfd, SOL_SOCKET, SO_ATTACH_FILTER, &fprog, sizeof(fprog)) < 0)
@@ -549,7 +549,7 @@ igmp_init(struct cfg *cfg)
/* can't set .sll_protocol to htons(ETH_P_IP), see comment above */
if (bind(sfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
error("bind: %m\n");
- goto out_fd;
+ goto error_fd;
}
debug(DBG_IGMP, "init successful, using fd %i\n", sfd);
@@ -563,8 +563,8 @@ igmp_init(struct cfg *cfg)
return;
-out_fd:
+error_fd:
close(sfd);
-out_free:
+error_free:
xfree(igmp);
}
diff --git a/rcon.c b/rcon.c
index 11383c2..bc8c681 100644
--- a/rcon.c
+++ b/rcon.c
@@ -275,7 +275,7 @@ rcon_login_reply(struct cfg *cfg, struct uring_task *task, int res)
if (res < 0) {
debug(DBG_RCON, "res: %i\n", res);
- goto out;
+ goto error;
}
debug(DBG_RCON, "packet complete\n");
@@ -283,13 +283,13 @@ rcon_login_reply(struct cfg *cfg, struct uring_task *task, int res)
if (id != 1) {
error("rcon login failed - unexpected reply id (%" PRIi32 ")\n", id);
- goto out;
+ goto error;
} else if (type == RCON_PACKET_LOGIN_FAIL) {
error("rcon login failed - incorrect password\n");
- goto out;
+ goto error;
} else if (type != RCON_PACKET_LOGIN_OK) {
error("rcon login failed - unexpected reply type (%" PRIi32 ")\n", type);
- goto out;
+ goto error;
}
debug(DBG_RCON, "rcon login successful\n");
@@ -297,7 +297,7 @@ rcon_login_reply(struct cfg *cfg, struct uring_task *task, int res)
uring_tbuf_write(cfg, &rcon->task, rcon_stop_sent);
return;
-out:
+error:
uring_task_put(cfg, &rcon->task);
}
diff --git a/server.c b/server.c
index cf66001..5025f18 100644
--- a/server.c
+++ b/server.c
@@ -230,13 +230,13 @@ server_local_open(struct cfg *cfg, struct server *scfg, struct server_local *loc
sfd = socket(local->local.storage.ss_family, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (sfd < 0) {
error("socket: %m");
- goto out;
+ goto error;
}
option = true;
if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option)) < 0) {
error("setsockopt: %m");
- goto out;
+ goto error;
}
/* The MC protocol expects the client to send data first */
@@ -255,20 +255,20 @@ server_local_open(struct cfg *cfg, struct server *scfg, struct server_local *loc
r = bind(sfd, (struct sockaddr *)&local->local.storage, local->local.addrlen);
if (r < 0) {
error("bind: %m");
- goto out;
+ goto error;
}
r = listen(sfd, 100);
if (r < 0) {
error("listen: %m");
- goto out;
+ goto error;
}
uring_task_set_fd(&local->task, sfd);
uring_accept(cfg, &local->task, &local->client, server_local_accept);
return true;
-out:
+error:
if (sfd >= 0)
close(sfd);
return false;
@@ -314,6 +314,7 @@ server_exec_done(struct cfg *cfg, struct uring_task *task, int res)
debug(DBG_SRV, "command successfully executed\n");
else
error("command failed: %i\n", info.si_status);
+
out:
uring_task_close_fd(cfg, &scfg->exec_task);
}