@samitouri / QOSamiQemu / commits / 4588ef5176

ati-vga: Avoid warnings about sign extension

Coverity reports several possible sign extension errors (latest is CID 1645615). These cannot happen because the values are limited when writing the registers and only 32 bits of the return value matter but change type of the variable storing the return value to uint32_t to avoid these warnings. Also change DEFAULT_SC_BOTTOM_RIGHT register read to match what other similar registers do for consistency. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-ID: <9a3263a06bc72aa5a56bafe0a11ad189d5f60528.1774110169.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

BALATON Zoltan committed Mar 21, 2026 at 17:30 UTC 4588ef5176f461bd27ba26bc894d0643f12464b4
1 file changed +4 -4
hw/display/ati.c
+4 -4
@@ -265,7 +265,7 @@ static void ati_vga_vblank_irq(void *opaque)
265 ati_vga_update_irq(s);
266 }
267
268 -static inline uint64_t ati_reg_read_offs(uint32_t reg, int offs,
268 +static inline uint32_t ati_reg_read_offs(uint32_t reg, int offs,
269 unsigned int size)
270 {
271 if (offs == 0 && size == 4) {
@@ -278,7 +278,7 @@ static inline uint64_t ati_reg_read_offs(uint32_t reg, int offs,
278 static uint64_t ati_mm_read(void *opaque, hwaddr addr, unsigned int size)
279 {
280 ATIVGAState *s = opaque;
281 - uint64_t val = 0;
281 + uint32_t val = 0;
282
283 switch (addr) {
284 case MM_INDEX:
@@ -513,8 +513,8 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr, unsigned int size)
513 val |= s->regs.default_tile << 16;
514 break;
515 case DEFAULT_SC_BOTTOM_RIGHT:
516 - val = (s->regs.default_sc_bottom << 16) |
517 - s->regs.default_sc_right;
516 + val = s->regs.default_sc_right;
517 + val |= s->regs.default_sc_bottom << 16;
518 break;
519 case SC_TOP:
520 val = s->regs.sc_top;