]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/display/xenfb: Replace unreachable code by g_assert_not_reached()
authorMarkus Armbruster <armbru@redhat.com>
Tue, 29 Jul 2025 11:12:26 +0000 (13:12 +0200)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Mon, 13 Oct 2025 19:00:09 +0000 (21:00 +0200)
xenfb_mouse_event() has a switch statement whose controlling
expression move->axis is an enum InputAxis.  The enum values are
INPUT_AXIS_X and INPUT_AXIS_Y, encoded as 0 and 1.  The switch has a
case for both axes.  In addition, it has an unreachable default label.
This convinces Coverity that move->axis can be greater than 1.  It
duly reports a buffer overrun when it is used to subscript an array
with two elements.

Replace the unreachable code by g_assert_not_reached().

Resolves: Coverity CID 1613906
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250729111226.3627499-1-armbru@redhat.com>
[PMD: s/abort/g_assert_not_reached/]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
hw/display/xenfb.c

index 22822fecea305d0908ee6c099509249f5516b1d2..164fd0b248571ea394ae3c97a9eec8d6c8278236 100644 (file)
@@ -283,8 +283,7 @@ static void xenfb_mouse_event(DeviceState *dev, QemuConsole *src,
                 scale = surface_height(surface) - 1;
                 break;
             default:
-                scale = 0x8000;
-                break;
+                g_assert_not_reached();
             }
             xenfb->axis[move->axis] = move->value * scale / 0x7fff;
         }