From e4d64e8752cf3fdf57a5bf1e34c02a7eccb5c6e6 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 7 Mar 2018 14:46:31 +0100 Subject: [PATCH] Initialize struct field by field Initializing with braces initializes the other fields to 0, which is not necessary. --- app/src/inputmanager.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/app/src/inputmanager.c b/app/src/inputmanager.c index dd273e93..ff9120ab 100644 --- a/app/src/inputmanager.c +++ b/app/src/inputmanager.c @@ -36,14 +36,11 @@ static SDL_bool is_ctrl_down(void) { static void send_keycode(struct controller *controller, enum android_keycode keycode, const char *name) { // send DOWN event - struct control_event control_event = { - .type = CONTROL_EVENT_TYPE_KEYCODE, - .keycode_event = { - .action = AKEY_EVENT_ACTION_DOWN, - .keycode = keycode, - .metastate = 0, - }, - }; + struct control_event control_event; + control_event.type = CONTROL_EVENT_TYPE_KEYCODE; + control_event.keycode_event.action = AKEY_EVENT_ACTION_DOWN; + control_event.keycode_event.keycode = keycode; + control_event.keycode_event.metastate = 0; if (!controller_push_event(controller, &control_event)) { LOGW("Cannot send %s (DOWN)", name); @@ -82,12 +79,10 @@ static inline void action_volume_down(struct controller *controller) { } static void turn_screen_on(struct controller *controller) { - struct control_event control_event = { - .type = CONTROL_EVENT_TYPE_COMMAND, - .command_event = { - .action = CONTROL_EVENT_COMMAND_SCREEN_ON, - }, - }; + struct control_event control_event; + control_event.type = CONTROL_EVENT_TYPE_COMMAND; + control_event.command_event.action = CONTROL_EVENT_COMMAND_SCREEN_ON; + if (!controller_push_event(controller, &control_event)) { LOGW("Cannot turn screen on"); }