[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen-mapcache: Fix a build error with -fexceptions


  • To: Alex Brett <alex.brett@xxxxxxxxxx>
  • From: Peter Maydell <peter.maydell@xxxxxxxxxx>
  • Date: Tue, 24 Nov 2026 13:23:52 +0000
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=1PIvKVm/9PMiiNfvrGshscRBFRehdozyDW1GHkg/J8Q=; fh=1qZLCUU5Fn6l+gRdTQRcYf8HOe3TXA3sR3e1Rf0T7Wk=; b=R9UFk7Lr7AgfGpDU5CyFPUI3e9xQI5FwzkeuBCXmMzXUmWGB+E/mxL6HIOWeDW6lFM 5QoxmluASqp29m4cUq7Hc8WTZ8V+AsxVSysF9HfKsxb12HEZ0xvuJfs3hnUkpu0+VdDQ IBIng6z5OqUrOegnOpNntRDgUj8wjmCh/2qMPnhK4BPLD/Q/Q3+rOF67xQn6zxfDL36D gxvkmdGtJxemPGN9fNjCmVF0e7IzHuitQI3PaghXduXl2TUhJhC+Hj49qrVv/GH/lyzQ YrHcslkXsIpo8jbJRVUVDHjRRtsLMOKlJXIR88W6PLRNQ3qHzKxHLRTI8xPAhXc/bv+D cDvQ==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1795526647; cv=none; d=google.com; s=arc-20260327; b=rkus9qNjzNgBsJi+BWRIZov/RuiD0lejjucAinsBcZPmw6KoQSSxSKq11DxPbcKb90 G2eSForMnyeNXAvc4stFEhvpKeMarvMDn27rubUkv/6/jhDd/tl1ibKONeLSZj9fiP4R dhIAlip/nPxy/rWKTb2rK9gwXJg/BM4vinNENQVKL1gymg4+0vsYF8BfBBnD6HwIZn51 2MVmdmgL6W21QoJ72EhdL6NP0S6zBsLS4IR6zbo3xETkrFA201zZHQqEZQw6AY64J3ox vFINjv2scoX9E9hujWO91/0rVFZjndawsmaquY4uQbbnM9dUDQzLM4x0pqX8sYaHqRJk esRw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=linaro.org header.i="@linaro.org" header.h="Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: qemu-devel@xxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony@xxxxxxxxxxxxxx>, "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 24 Nov 2026 13:24:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.