From 0a9be883873b5670cdade26b0c27d9dba14a0be8 Mon Sep 17 00:00:00 2001 From: Niklas Dusenlund Date: Mon, 6 Oct 2025 09:34:59 +0200 Subject: [PATCH] ui: Remove noop `.on_event` is allowed to be NULL --- src/ui/components/empty.c | 2 +- src/ui/components/image.c | 2 +- src/ui/components/info_centered.c | 2 +- src/ui/components/knight_rider.c | 2 +- src/ui/components/lockscreen.c | 2 +- src/ui/components/orientation_arrows.c | 2 +- src/ui/components/progress.c | 2 +- src/ui/components/screensaver.c | 2 +- src/ui/components/sdcard.c | 2 +- src/ui/components/status.c | 2 +- src/ui/components/trinary_choice.c | 2 +- src/ui/components/waiting.c | 2 +- src/ui/ui_util.c | 12 ------------ src/ui/ui_util.h | 7 ------- test/hardware-fakes/src/fake_component.c | 2 +- 15 files changed, 13 insertions(+), 32 deletions(-) diff --git a/src/ui/components/empty.c b/src/ui/components/empty.c index 384960f959..13b57ed39f 100644 --- a/src/ui/components/empty.c +++ b/src/ui/components/empty.c @@ -21,7 +21,7 @@ static const component_functions_t _component_functions = { .cleanup = ui_util_component_cleanup, .render = ui_util_component_render_subcomponents, - .on_event = ui_util_on_event_noop, + .on_event = NULL, }; /********************************** Create Instance **********************************/ diff --git a/src/ui/components/image.c b/src/ui/components/image.c index 383593e74b..def3460c54 100644 --- a/src/ui/components/image.c +++ b/src/ui/components/image.c @@ -48,7 +48,7 @@ static void _render(component_t* component) static const component_functions_t _component_functions = { .cleanup = ui_util_component_cleanup, .render = _render, - .on_event = ui_util_on_event_noop, + .on_event = NULL, }; /********************************** Create Instance **********************************/ diff --git a/src/ui/components/info_centered.c b/src/ui/components/info_centered.c index ddd5e1193b..5e4f2c392b 100644 --- a/src/ui/components/info_centered.c +++ b/src/ui/components/info_centered.c @@ -30,7 +30,7 @@ static const component_functions_t _component_functions = { .cleanup = ui_util_component_cleanup, .render = ui_util_component_render_subcomponents, - .on_event = ui_util_on_event_noop, + .on_event = NULL, }; /********************************** Create Instance **********************************/ diff --git a/src/ui/components/knight_rider.c b/src/ui/components/knight_rider.c index 92d37fdf05..eeb8e5717c 100644 --- a/src/ui/components/knight_rider.c +++ b/src/ui/components/knight_rider.c @@ -50,7 +50,7 @@ static void _render(component_t* component) static component_functions_t _component_functions = { .cleanup = ui_util_component_cleanup, .render = _render, - .on_event = ui_util_on_event_noop, + .on_event = NULL, }; /********************************** Create Instance **********************************/ diff --git a/src/ui/components/lockscreen.c b/src/ui/components/lockscreen.c index 32f015a59b..42a32e6ba8 100644 --- a/src/ui/components/lockscreen.c +++ b/src/ui/components/lockscreen.c @@ -31,7 +31,7 @@ static const component_functions_t _component_functions = { .cleanup = ui_util_component_cleanup, .render = ui_util_component_render_subcomponents, - .on_event = ui_util_on_event_noop, + .on_event = NULL, }; /********************************** Create Instance **********************************/ diff --git a/src/ui/components/orientation_arrows.c b/src/ui/components/orientation_arrows.c index 5689f32f4d..1de20389c9 100644 --- a/src/ui/components/orientation_arrows.c +++ b/src/ui/components/orientation_arrows.c @@ -142,7 +142,7 @@ static void _render(component_t* component) static component_functions_t _component_functions = { .cleanup = ui_util_component_cleanup, .render = _render, - .on_event = ui_util_on_event_noop, + .on_event = NULL, }; /********************************** Create Instance **********************************/ diff --git a/src/ui/components/progress.c b/src/ui/components/progress.c index fd0a2d03ca..987459325b 100644 --- a/src/ui/components/progress.c +++ b/src/ui/components/progress.c @@ -38,7 +38,7 @@ static void _render(component_t* component) static const component_functions_t _component_functions = { .cleanup = ui_util_component_cleanup, .render = _render, - .on_event = ui_util_on_event_noop, + .on_event = NULL, }; component_t* progress_create(const char* title) diff --git a/src/ui/components/screensaver.c b/src/ui/components/screensaver.c index d3dd32a9fd..7f0eb80387 100644 --- a/src/ui/components/screensaver.c +++ b/src/ui/components/screensaver.c @@ -71,7 +71,7 @@ static void _render(component_t* component) static component_functions_t _component_functions = { .cleanup = ui_util_component_cleanup, .render = _render, - .on_event = ui_util_on_event_noop, + .on_event = NULL, }; component_t* screensaver_create(void) diff --git a/src/ui/components/sdcard.c b/src/ui/components/sdcard.c index 0dc7b043d4..2df6c54af6 100644 --- a/src/ui/components/sdcard.c +++ b/src/ui/components/sdcard.c @@ -59,7 +59,7 @@ static void _render(component_t* component) static const component_functions_t _component_functions = { .cleanup = ui_util_component_cleanup, .render = _render, - .on_event = ui_util_on_event_noop, + .on_event = NULL, }; /********************************** Create Instance **********************************/ diff --git a/src/ui/components/status.c b/src/ui/components/status.c index 962d753f96..d7ce208844 100644 --- a/src/ui/components/status.c +++ b/src/ui/components/status.c @@ -55,7 +55,7 @@ static void _render(component_t* component) static const component_functions_t _component_functions = { .cleanup = ui_util_component_cleanup, .render = _render, - .on_event = ui_util_on_event_noop, + .on_event = NULL, }; /********************************** Create Instance **********************************/ diff --git a/src/ui/components/trinary_choice.c b/src/ui/components/trinary_choice.c index 88d65cb93d..d071f3b1c5 100644 --- a/src/ui/components/trinary_choice.c +++ b/src/ui/components/trinary_choice.c @@ -33,7 +33,7 @@ typedef struct { static const component_functions_t _component_functions = { .cleanup = ui_util_component_cleanup, .render = ui_util_component_render_subcomponents, - .on_event = ui_util_on_event_noop, + .on_event = NULL, }; static void _left_selected(component_t* button) diff --git a/src/ui/components/waiting.c b/src/ui/components/waiting.c index d284f4d8ee..88b7513789 100644 --- a/src/ui/components/waiting.c +++ b/src/ui/components/waiting.c @@ -37,7 +37,7 @@ static void _render(component_t* component) static component_functions_t _component_functions = { .cleanup = ui_util_component_cleanup, .render = _render, - .on_event = ui_util_on_event_noop, + .on_event = NULL, }; /********************************** Create Instance **********************************/ diff --git a/src/ui/ui_util.c b/src/ui/ui_util.c index 1e9f97ffc8..e312ba94e5 100644 --- a/src/ui/ui_util.c +++ b/src/ui/ui_util.c @@ -63,18 +63,6 @@ void ui_util_component_cleanup(component_t* component) free(component); } -/** - * A no-op function for components that do not handle events. - * @param[in] event The emitted event. - * @param[in] component The component that receives the event. - */ -void ui_util_on_event_noop(const event_t* event, component_t* component) -{ - // noop - (void)event; - (void)component; -} - /** * Positions the child component in the center (vertical and horizontal) of the * parent component. diff --git a/src/ui/ui_util.h b/src/ui/ui_util.h index 6baba90831..09b42065ed 100644 --- a/src/ui/ui_util.h +++ b/src/ui/ui_util.h @@ -53,13 +53,6 @@ void ui_util_component_render_subcomponents(component_t* component); */ void ui_util_component_cleanup(component_t* component); -/** - * A no-op function for components that do not handle events. - * @param[in] event The emitted event. - * @param[in] component The component that receives the event. - */ -void ui_util_on_event_noop(const event_t* event, component_t* component); - /** * Positions the child component in the center (vertical and horizontal) of the * parent component. diff --git a/test/hardware-fakes/src/fake_component.c b/test/hardware-fakes/src/fake_component.c index faf4909102..a0ad383950 100644 --- a/test/hardware-fakes/src/fake_component.c +++ b/test/hardware-fakes/src/fake_component.c @@ -28,7 +28,7 @@ static const component_functions_t FAKE_COMPONENT_FUNCTIONS = { .cleanup = ui_util_component_cleanup, .render = ui_util_component_render_subcomponents, - .on_event = ui_util_on_event_noop}; + .on_event = NULL}; /********************************** Create Instance **********************************/