summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-23 19:58:59 +0200
committerLennart Poettering <lennart@poettering.net>2015-09-29 21:55:51 +0200
commit00411a134331cb6ffe6479407df0d496d24a236a (patch)
tree2e7614939dc15db1ebe72363abf545bbdc470cc8 /src/core
parent710a6b5017ba23fde6713f55340db5390ea27cec (diff)
core: turn a large if statement into a switch
Diffstat (limited to 'src/core')
-rw-r--r--src/core/socket.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index 55ecada5ee..203d008129 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1222,7 +1222,9 @@ static int socket_open_fds(Socket *s) {
if (p->fd >= 0)
continue;
- if (p->type == SOCKET_SOCKET) {
+ switch (p->type) {
+
+ case SOCKET_SOCKET:
if (!know_label) {
/* Figure out label, if we don't it know
@@ -1273,16 +1275,18 @@ static int socket_open_fds(Socket *s) {
p->fd = r;
socket_apply_socket_options(s, p->fd);
socket_symlink(s);
+ break;
- } else if (p->type == SOCKET_SPECIAL) {
+ case SOCKET_SPECIAL:
p->fd = special_address_create(p->path);
if (p->fd < 0) {
r = p->fd;
goto rollback;
}
+ break;
- } else if (p->type == SOCKET_FIFO) {
+ case SOCKET_FIFO:
p->fd = fifo_address_create(
p->path,
@@ -1295,8 +1299,9 @@ static int socket_open_fds(Socket *s) {
socket_apply_fifo_options(s, p->fd);
socket_symlink(s);
+ break;
- } else if (p->type == SOCKET_MQUEUE) {
+ case SOCKET_MQUEUE:
p->fd = mq_address_create(
p->path,
@@ -1307,8 +1312,9 @@ static int socket_open_fds(Socket *s) {
r = p->fd;
goto rollback;
}
+ break;
- } else if (p->type == SOCKET_USB_FUNCTION) {
+ case SOCKET_USB_FUNCTION:
p->fd = ffs_address_create(p->path);
if (p->fd < 0) {
@@ -1323,8 +1329,12 @@ static int socket_open_fds(Socket *s) {
r = ffs_dispatch_eps(p);
if (r < 0)
goto rollback;
- } else
+
+ break;
+
+ default:
assert_not_reached("Unknown port type");
+ }
}
return 0;