]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
expo: Tidy up scene_txt_render()
authorSimon Glass <sjg@chromium.org>
Fri, 2 May 2025 14:46:39 +0000 (08:46 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 30 May 2025 08:49:32 +0000 (09:49 +0100)
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>
boot/scene.c

index da3d30a9cab5281fba80c2283a4c6ba36e1b290d..aacdccdce17106cbd69393001f56530ad09c95cf 100644 (file)
@@ -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;
 }