[PATCH] hw/xtensa: replace calloc with g_new0 in mx_pic

Ajinkya Udgirkar posted 1 patch 3 days, 4 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260604162849.199541-1-audgirka@redhat.com
Maintainers: Max Filippov <jcmvbkbc@gmail.com>
hw/xtensa/mx_pic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] hw/xtensa: replace calloc with g_new0 in mx_pic
Posted by Ajinkya Udgirkar 3 days, 4 hours ago
Replace libc calloc() with GLib g_new0() for consistency with the
rest of the QEMU codebase. g_new0() aborts on allocation failure
rather than returning NULL, which matches QEMU's allocation policy.

Signed-off-by: Ajinkya Udgirkar <audgirka@redhat.com>
---
 hw/xtensa/mx_pic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/xtensa/mx_pic.c b/hw/xtensa/mx_pic.c
index 098c1aa..8ded3bc 100644
--- a/hw/xtensa/mx_pic.c
+++ b/hw/xtensa/mx_pic.c
@@ -343,7 +343,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,
-- 
2.54.0
Re: [PATCH] hw/xtensa: replace calloc with g_new0 in mx_pic
Posted by Max Filippov 29 minutes ago
On Thu, Jun 4, 2026 at 9:29 AM Ajinkya Udgirkar
<ajinkyaudgirkar@gmail.com> wrote:
>
> Replace libc calloc() with GLib g_new0() for consistency with the
> rest of the QEMU codebase. g_new0() aborts on allocation failure
> rather than returning NULL, which matches QEMU's allocation policy.
>
> Signed-off-by: Ajinkya Udgirkar <audgirka@redhat.com>
> ---
>  hw/xtensa/mx_pic.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max