[Concept,08/22] video: Move setting of cte in write_pix8() to the top

Message ID 20251003165525.440173-9-sjg@u-boot.org
State New
Headers
Series video: Enhancements to support a pointer |

Commit Message

Simon Glass Oct. 3, 2025, 4:55 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

The compiler can deal with the complexity of deciding whether to set up
this local. Move it to the top of the function.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/video/video_bmp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c
index 478b8fbe5fd..390996dbaf1 100644
--- a/drivers/video/video_bmp.c
+++ b/drivers/video/video_bmp.c
@@ -68,14 +68,14 @@  static u32 get_bmp_col_rgba8888(struct bmp_color_table_entry *cte)
 static void write_pix8(u8 *fb, uint bpix, enum video_format eformat,
 		       struct bmp_color_table_entry *palette, u8 *bmap)
 {
+	struct bmp_color_table_entry *cte = &palette[*bmap];
+
 	if (bpix == 8) {
 		*fb++ = *bmap;
 	} else if (bpix == 16) {
-		*(u16 *)fb = get_bmp_col_16bpp(palette[*bmap]);
+		*(u16 *)fb = get_bmp_col_16bpp(*cte);
 	} else {
 		/* Only support big endian */
-		struct bmp_color_table_entry *cte = &palette[*bmap];
-
 		if (bpix == 24) {
 			*fb++ = cte->red;
 			*fb++ = cte->green;