1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-08 11:27:32 +03:00

core: turn a large if statement into a switch

This commit is contained in:
Lennart Poettering 2015-09-23 19:58:59 +02:00
parent 710a6b5017
commit 00411a1343

View File

@ -1222,7 +1222,9 @@ static int socket_open_fds(Socket *s) {
if (p->fd >= 0) if (p->fd >= 0)
continue; continue;
if (p->type == SOCKET_SOCKET) { switch (p->type) {
case SOCKET_SOCKET:
if (!know_label) { if (!know_label) {
/* Figure out label, if we don't it know /* Figure out label, if we don't it know
@ -1273,16 +1275,18 @@ static int socket_open_fds(Socket *s) {
p->fd = r; p->fd = r;
socket_apply_socket_options(s, p->fd); socket_apply_socket_options(s, p->fd);
socket_symlink(s); socket_symlink(s);
break;
} else if (p->type == SOCKET_SPECIAL) { case SOCKET_SPECIAL:
p->fd = special_address_create(p->path); p->fd = special_address_create(p->path);
if (p->fd < 0) { if (p->fd < 0) {
r = p->fd; r = p->fd;
goto rollback; goto rollback;
} }
break;
} else if (p->type == SOCKET_FIFO) { case SOCKET_FIFO:
p->fd = fifo_address_create( p->fd = fifo_address_create(
p->path, p->path,
@ -1295,8 +1299,9 @@ static int socket_open_fds(Socket *s) {
socket_apply_fifo_options(s, p->fd); socket_apply_fifo_options(s, p->fd);
socket_symlink(s); socket_symlink(s);
break;
} else if (p->type == SOCKET_MQUEUE) { case SOCKET_MQUEUE:
p->fd = mq_address_create( p->fd = mq_address_create(
p->path, p->path,
@ -1307,8 +1312,9 @@ static int socket_open_fds(Socket *s) {
r = p->fd; r = p->fd;
goto rollback; goto rollback;
} }
break;
} else if (p->type == SOCKET_USB_FUNCTION) { case SOCKET_USB_FUNCTION:
p->fd = ffs_address_create(p->path); p->fd = ffs_address_create(p->path);
if (p->fd < 0) { if (p->fd < 0) {
@ -1323,9 +1329,13 @@ static int socket_open_fds(Socket *s) {
r = ffs_dispatch_eps(p); r = ffs_dispatch_eps(p);
if (r < 0) if (r < 0)
goto rollback; goto rollback;
} else
break;
default:
assert_not_reached("Unknown port type"); assert_not_reached("Unknown port type");
} }
}
return 0; return 0;