diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2021-12-12 19:49:35 +0100 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2021-12-12 19:49:35 +0100 |
| commit | 8f90aa5415adb3f28d9f14069e7e3b395784f825 (patch) | |
| tree | e49be756f26df65bad8419beac0a5a7fc86728eb /swaymsg/main.c | |
| parent | e16145566b113f7a59cb6af310ea882346412e37 (diff) | |
swaymsg: replace if with switch in pretty_print
Diffstat (limited to 'swaymsg/main.c')
| -rw-r--r-- | swaymsg/main.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/swaymsg/main.c b/swaymsg/main.c index 0d9dc5a0..b58c673c 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c @@ -289,27 +289,25 @@ static void pretty_print_config(json_object *c) { } static void pretty_print(int type, json_object *resp) { - if (type != IPC_COMMAND && type != IPC_GET_WORKSPACES && - type != IPC_GET_INPUTS && type != IPC_GET_OUTPUTS && - type != IPC_GET_VERSION && type != IPC_GET_SEATS && - type != IPC_GET_CONFIG && type != IPC_SEND_TICK) { - printf("%s\n", json_object_to_json_string_ext(resp, - JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED)); - return; - } - - if (type == IPC_SEND_TICK) { + switch (type) { + case IPC_SEND_TICK: return; - } - - if (type == IPC_GET_VERSION) { + case IPC_GET_VERSION: pretty_print_version(resp); return; - } - - if (type == IPC_GET_CONFIG) { + case IPC_GET_CONFIG: pretty_print_config(resp); return; + case IPC_COMMAND: + case IPC_GET_WORKSPACES: + case IPC_GET_INPUTS: + case IPC_GET_OUTPUTS: + case IPC_GET_SEATS: + break; + default: + printf("%s\n", json_object_to_json_string_ext(resp, + JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED)); + return; } json_object *obj; |
