|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] xen-mapcache: Fix a build error with -fexceptions
On Tue, 24 Nov 2026 at 13:14, Alex Brett via qemu development <qemu-devel@xxxxxxxxxx> wrote: > > When building with -Werror=maybe-uninitialized and -fexceptions, gcc can > report: > error: 'err' may be used uninitialized [-Werror=maybe-uninitialized] > > err gets assigned to g_new0() unconditionally, but under -fexceptions > the calls to trace_xen_remap_bucket() or g_new0() might unwind, leading > the g_autofree cleanup to run g_free() on an uninitialised err. Avoid > the warning and any future issues by initialising it to NULL in the same > pattern as other definitions. > > Signed-off-by: Alex Brett <alex.brett@xxxxxxxxxx> > --- > hw/xen/xen-mapcache.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c > index e30c07c2ee..0a19cfdc1b 100644 > --- a/hw/xen/xen-mapcache.c > +++ b/hw/xen/xen-mapcache.c > @@ -199,7 +199,7 @@ static void xen_remap_bucket(MapCache *mc, > uint8_t *vaddr_base; > g_autofree uint32_t *refs = NULL; > g_autofree xen_pfn_t *pfns = NULL; > - g_autofree int *err; > + g_autofree int *err = NULL; > unsigned int i; > hwaddr nb_pfn = size >> XC_PAGE_SHIFT; Explicit init of a g_autofree pointer is the recommended pattern, so Reviewed-by: Peter Maydell <peter.maydell@xxxxxxxxxx> but why are you building with "-fexceptions" ? Trying to throw a C++ exception through QEMU's C code seems like it's likely to run into all kinds of problems and corner cases... thanks -- PMM
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |