All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Christian S. Lima" <christianslima@proton.me>
Cc: qemu-devel@nongnu.org,  Laurent Vivier <laurent@vivier.eu>
Subject: Re: [PATCH] disas: converts malloc to g_malloc0
Date: Tue, 30 Jun 2026 06:55:29 +0200	[thread overview]
Message-ID: <87qzlor5j2.fsf@pond.sub.org> (raw)
In-Reply-To: <20260630005249.143976-1-christianslima@proton.me> (Christian S. Lima's message of "Tue, 30 Jun 2026 00:52:56 +0000")

"Christian S. Lima" <christianslima@proton.me> writes:

> Following the qemu coding style change malloc to g_malloc, the
> advantages are that g_malloc will exit if some failure occur and
> initialize all memory with zeros.

Any particular reason to initialize, or is it "just in case"?

> Signed-off-by: Christian S. Lima <christianslima@proton.me>
> ---
>  disas/m68k.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/disas/m68k.c b/disas/m68k.c
> index 800b4145ac..e629f3c365 100644
> --- a/disas/m68k.c
> +++ b/disas/m68k.c
> @@ -1887,8 +1887,8 @@ print_insn_m68k (bfd_vma memaddr, disassemble_info *info)
>  
>        /* Then create a sorted table of pointers
>  	 that point into the unsorted table.  */
> -      opc_pointer[0] = malloc (sizeof (struct m68k_opcode *)
> -                               * m68k_numopcodes);
> +      opc_pointer[0] = g_malloc0 (sizeof (struct m68k_opcode)
> +                                  * m68k_numopcodes);
>        opcodes[0] = opc_pointer[0];
>  
>        for (i = 1; i < 16; i++)

g_new0(struct m68k_opcode, m68k_numopcodes) would be more obviously
safe, because it checks the multiplication for for overflow.



  reply	other threads:[~2026-06-30  4:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30  0:52 [PATCH] disas: converts malloc to g_malloc0 Christian S. Lima
2026-06-30  4:55 ` Markus Armbruster [this message]
2026-06-30  6:02   ` Christian
2026-06-30  6:53     ` Markus Armbruster
2026-06-30 21:41       ` Christian

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=87qzlor5j2.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=christianslima@proton.me \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.