From bc6adbe15dd82ea2a02dbe1b95348eba1d9d647e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Mon, 31 May 2021 20:27:21 +0200 Subject: [PATCH] pulse-server: make control flow easier to unserstand Use a switch statement to make the control flow a bit easier to understand. --- .../module-protocol-pulse/pulse-server.c | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index bc72bf10c..08bde2e2e 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -5630,15 +5630,19 @@ on_client_data(void *data, int fd, uint32_t mask) return; error: - if (res == -EPIPE) - pw_log_info(NAME" %p: client:%p [%s] disconnected", impl, client, client->name); - else if (res != -EPROTO) { - pw_log_error(NAME" %p: client:%p [%s] error %d (%s)", impl, - client, client->name, res, spa_strerror(res)); - return; + switch (res) { + case -EPIPE: + pw_log_info(NAME" %p: client:%p [%s] disconnected", impl, client, client->name); + SPA_FALLTHROUGH; + case -EPROTO: + client_disconnect(client); + client_unref(client); + break; + default: + pw_log_error(NAME" %p: client:%p [%s] error %d (%s)", impl, + client, client->name, res, spa_strerror(res)); + break; } - client_disconnect(client); - client_unref(client); } static int check_flatpak(struct client *client, int pid)