From 6b769675fa68e60c9765022e43c4d7b1e329353a Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Sun, 12 Mar 2023 14:23:35 +0800 Subject: [PATCH] Fix an "expected expression" error In C, a label can only be followed by a statement, not a declaration. An error in `app/src/screen.c` violated this, and led to a build error with an error message similar to the one below: ../app/src/screen.c:821:13: error: expected expression bool ok = sc_screen_init_size(screen); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/include/stdbool.h:15:14: note: expanded from macro 'bool' #define bool _Bool ^ ../app/src/screen.c:822:18: error: use of undeclared identifier 'ok' if (!ok) { ^ 2 errors generated. This could be fixed by introducing a new block (or compound statement; as is already being done in the next `case`). That is a statement. Fixes #3785 PR #3787 Signed-off-by: Ruoyu Zhong Signed-off-by: Romain Vimont --- app/src/screen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/screen.c b/app/src/screen.c index f74fd8a5..b00b0d05 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -816,7 +816,7 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { bool relative_mode = sc_screen_is_relative_mode(screen); switch (event->type) { - case SC_EVENT_SCREEN_INIT_SIZE: + case SC_EVENT_SCREEN_INIT_SIZE: { // The initial size is passed via screen->frame_size bool ok = sc_screen_init_size(screen); if (!ok) { @@ -824,6 +824,7 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { return false; } return true; + } case SC_EVENT_NEW_FRAME: { bool ok = sc_screen_update_frame(screen); if (!ok) {