[PATCH] hw/xtensa: convert calloc to g_new0 in mx_pic.c

Manish posted 1 patch 2 days, 1 hour ago
Failed in applying to current master (apply log)
There is a newer version of this series
hw/xtensa/mx_pic.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] hw/xtensa: convert calloc to g_new0 in mx_pic.c
Posted by Manish 2 days, 1 hour ago
From cef7f1f3d7b47338b7359ad4b815e04bc965d427 Mon Sep 17 00:00:00 2001
From: "Manish." <manishyoudumb@gmail.com>
Date: Sat, 7 Feb 2026 23:26:09 +0530
Subject: [PATCH] hw/xtensa: convert calloc to g_new0 in mx_pic.c

Convert the calloc allocation in xtensa_mx_pic_init() to use
g_new0() for consistency.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1798

Signed-off-by: Manish. <manishyoudumb@gmail.com>
---
hw/xtensa/mx_pic.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/xtensa/mx_pic.c b/hw/xtensa/mx_pic.c
index 07c3731aef..ab308c9490 100644
--- a/hw/xtensa/mx_pic.c
+++ b/hw/xtensa/mx_pic.c
@@ -316,8 +316,7 @@ static void xtensa_mx_pic_set_irq(void *opaque,
int irq, int active)
XtensaMxPic *xtensa_mx_pic_init(unsigned n_irq)
{
- XtensaMxPic *mx = calloc(1, sizeof(XtensaMxPic));
-
+ XtensaMxPic *mx = g_new0(XtensaMxPic, 1);
mx->n_irq = n_irq + 1;
mx->irq_inputs = qemu_allocate_irqs(xtensa_mx_pic_set_irq, mx,
mx->n_irq);
--
2.52.0
Re: [PATCH] hw/xtensa: convert calloc to g_new0 in mx_pic.c
Posted by Max Filippov 1 day, 21 hours ago
On Sat, Feb 7, 2026 at 10:16 AM Manish <manishyoudumb@gmail.com> wrote:
>
> From cef7f1f3d7b47338b7359ad4b815e04bc965d427 Mon Sep 17 00:00:00 2001
> From: "Manish." <manishyoudumb@gmail.com>
> Date: Sat, 7 Feb 2026 23:26:09 +0530
> Subject: [PATCH] hw/xtensa: convert calloc to g_new0 in mx_pic.c
>
> Convert the calloc allocation in xtensa_mx_pic_init() to use
> g_new0() for consistency.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1798
>
> Signed-off-by: Manish. <manishyoudumb@gmail.com>
> ---
> hw/xtensa/mx_pic.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)

The patch is damaged and would not apply, but the change looks good to me.
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>

> diff --git a/hw/xtensa/mx_pic.c b/hw/xtensa/mx_pic.c
> index 07c3731aef..ab308c9490 100644
> --- a/hw/xtensa/mx_pic.c
> +++ b/hw/xtensa/mx_pic.c
> @@ -316,8 +316,7 @@ static void xtensa_mx_pic_set_irq(void *opaque,
> int irq, int active)
> XtensaMxPic *xtensa_mx_pic_init(unsigned n_irq)
> {
> - XtensaMxPic *mx = calloc(1, sizeof(XtensaMxPic));
> -
> + XtensaMxPic *mx = g_new0(XtensaMxPic, 1);
> mx->n_irq = n_irq + 1;
> mx->irq_inputs = qemu_allocate_irqs(xtensa_mx_pic_set_irq, mx,
> mx->n_irq);
> --
> 2.52.0

-- 
Thanks.
-- Max