treewide: remove empty statements in switch cases

For longer cases, factor out the logic to new functions.
For very short cases, just move the declaration before the switch.

v2: in one case, replace the switch with if/else.
This commit is contained in:
John Lindgren 2025-05-22 10:53:58 -04:00 committed by Johan Malm
parent fbb92e2e30
commit a3d6226728
5 changed files with 59 additions and 50 deletions

View file

@ -147,6 +147,7 @@ handle_sigchld(int signal, void *data)
return 0;
}
const char *signame;
switch (info.si_code) {
case CLD_EXITED:
wlr_log(info.si_status == 0 ? WLR_DEBUG : WLR_ERROR,
@ -155,8 +156,7 @@ handle_sigchld(int signal, void *data)
break;
case CLD_KILLED:
case CLD_DUMPED:
; /* works around "a label can only be part of a statement" */
const char *signame = strsignal(info.si_status);
signame = strsignal(info.si_status);
wlr_log(WLR_ERROR,
"spawned child %ld terminated with signal %d (%s)",
(long)info.si_pid, info.si_status,