diff options
author | Simon Glass <sjg@chromium.org> | 2025-05-02 08:46:39 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2025-05-30 09:49:32 +0100 |
commit | 589e4ccacfc6ef347a78386b8bedc666911e9c4c (patch) | |
tree | 62beef135dbc1addc40ce326732ee45d667ba5df | |
parent | ead673dd24e2c965b8e222d5e866f1d94aeb69b5 (diff) |
expo: Tidy up scene_txt_render()
Add an early return if there is no string. Move all declarations to the
top of the function.
Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | boot/scene.c | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/boot/scene.c b/boot/scene.c index da3d30a9cab..aacdccdce17 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -418,6 +418,9 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev, struct scene_txt_generic *gen, int x, int y, int menu_inset) { + struct video_priv *vid_priv; + struct vidconsole_colour old; + enum colour_idx fore, back; const char *str; int ret; @@ -433,32 +436,27 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev, if (ret && ret != -ENOSYS) return log_msg_ret("font", ret); str = expo_get_str(exp, gen->str_id); - if (str) { - struct video_priv *vid_priv; - struct vidconsole_colour old; - enum colour_idx fore, back; - - vid_priv = dev_get_uclass_priv(dev); - if (vid_priv->white_on_black) { - fore = VID_BLACK; - back = VID_WHITE; - } else { - fore = VID_LIGHT_GRAY; - back = VID_BLACK; - } + if (!str) + return 0; - if (obj->flags & SCENEOF_POINT) { - vidconsole_push_colour(cons, fore, back, &old); - video_fill_part(dev, x - menu_inset, y, - obj->bbox.x1, - obj->bbox.y1, - vid_priv->colour_bg); - } - vidconsole_set_cursor_pos(cons, x, y); - vidconsole_put_string(cons, str); - if (obj->flags & SCENEOF_POINT) - vidconsole_pop_colour(cons, &old); + vid_priv = dev_get_uclass_priv(dev); + if (vid_priv->white_on_black) { + fore = VID_BLACK; + back = VID_WHITE; + } else { + fore = VID_LIGHT_GRAY; + back = VID_BLACK; + } + + if (obj->flags & SCENEOF_POINT) { + vidconsole_push_colour(cons, fore, back, &old); + video_fill_part(dev, x - menu_inset, y, obj->bbox.x1, + obj->bbox.y1, vid_priv->colour_bg); } + vidconsole_set_cursor_pos(cons, x, y); + vidconsole_put_string(cons, str); + if (obj->flags & SCENEOF_POINT) + vidconsole_pop_colour(cons, &old); return 0; } |