qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH] block: Simplify a few g_try_malloc() error checks
Date: Tue, 27 Jan 2015 14:01:24 +0100	[thread overview]
Message-ID: <54C78C24.2030304@redhat.com> (raw)
In-Reply-To: <1422361514-25226-1-git-send-email-armbru@redhat.com>



On 27/01/2015 13:25, Markus Armbruster wrote:
> Unlike malloc(), g_try_malloc() & friends return a null pointer only
> on failure, never for a zero size.  Simplify tests for failure
> accordingly.  This helps Coverity see returned null pointers can't be
> dereferenced.  Also makes the code easier to read.

Unfortunately that's not what I see from the source:

gpointer
g_try_malloc (gsize n_bytes)
{
  gpointer mem;

  if (G_LIKELY (n_bytes))
    mem = glib_mem_vtable.try_malloc (n_bytes);
  else
    mem = NULL;

  TRACE (GLIB_MEM_ALLOC((void*) mem, (unsigned int) n_bytes, 0, 1));

  return mem;
}

Paolo

  reply	other threads:[~2015-01-27 13:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-27 12:25 [Qemu-devel] [PATCH] block: Simplify a few g_try_malloc() error checks Markus Armbruster
2015-01-27 13:01 ` Paolo Bonzini [this message]
2015-01-27 13:42   ` Markus Armbruster
2015-01-27 14:07     ` Kevin Wolf

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=54C78C24.2030304@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).