From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: Markus Armbruster <armbru@redhat.com>,
qemu-devel@nongnu.org, sstabellini@kernel.org,
anthony@xenproject.org, paul@xen.org, edgar.iglesias@gmail.com,
xen-devel@lists.xenproject.org, qemu-trivial@nongnu.org
Subject: Re: [PATCH] hw/display/xenfb: Replace unreachable code by abort()
Date: Tue, 29 Jul 2025 14:16:56 +0100 [thread overview]
Message-ID: <aIjJyH_Vy0LzHH4z@redhat.com> (raw)
In-Reply-To: <15536eea-5a66-4dff-b4bd-8a43fbfa9365@linaro.org>
On Tue, Jul 29, 2025 at 02:59:46PM +0200, Philippe Mathieu-Daudé wrote:
> On 29/7/25 14:16, Markus Armbruster wrote:
> > Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> >
> > > On 29/7/25 13:12, Markus Armbruster wrote:
> > > > 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 abort().
> > > > Resolves: Coverity CID 1613906
> > > > Signed-off-by: Markus Armbruster <armbru@redhat.com>
> > > > ---
> > > > hw/display/xenfb.c | 3 +--
> > > > 1 file changed, 1 insertion(+), 2 deletions(-)
> > > > diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
> > > > index 22822fecea..5e6c691779 100644
> > > > --- a/hw/display/xenfb.c
> > > > +++ b/hw/display/xenfb.c
> > > > @@ -283,8 +283,7 @@ static void xenfb_mouse_event(DeviceState *dev, QemuConsole *src,
> > > > scale = surface_height(surface) - 1;
> > > > break;
> > > > default:
> > > > - scale = 0x8000;
> > > > - break;
> > > > + abort();
> > >
> > > We prefer GLib g_assert_not_reached() over abort() because it displays
> > > the file, line number & function before aborting.
> >
> > The purpose of this line is to tell the compiler we can't get there,
> > with the least amount of ceremony.
> >
> > We have ~600 calls of abort().
>
> And ~1600 of g_assert_not_reached() =)
>
> $ git grep -w 'abort();' | wc -l
> 556
> $ git grep -w 'g_assert_not_reached();' | wc -l
> 1551
Sounds like we could create a gitlab issue for "replace abort with
g_assert_not_reached" that could be a easy on-ramp for someone to
start contributing.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
prev parent reply other threads:[~2025-07-29 13:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 11:12 [PATCH] hw/display/xenfb: Replace unreachable code by abort() Markus Armbruster
2025-07-29 11:26 ` Philippe Mathieu-Daudé
2025-07-29 12:16 ` Markus Armbruster
2025-07-29 12:59 ` Philippe Mathieu-Daudé
2025-07-29 13:16 ` Daniel P. Berrangé [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aIjJyH_Vy0LzHH4z@redhat.com \
--to=berrange@redhat.com \
--cc=anthony@xenproject.org \
--cc=armbru@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=paul@xen.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).