All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rjones@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, den@openvz.org,
	rkagan@virtuozzo.com, dplotnikov@virtuozzo.com,
	berrange@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] qemu-nbd: Implement socket activation.
Date: Fri, 3 Feb 2017 16:52:09 +0000	[thread overview]
Message-ID: <20170203165209.GZ15182@redhat.com> (raw)
In-Reply-To: <20170203151643.GG642@stefanha-x1.localdomain>

On Fri, Feb 03, 2017 at 03:16:43PM +0000, Stefan Hajnoczi wrote:
> On Thu, Feb 02, 2017 at 05:16:25PM +0000, Richard W.M. Jones wrote:
> > +    if (*port == NULL) {
> > +        *port = g_strdup_printf("%d", NBD_DEFAULT_PORT);;
> 
> Please stringify NBD_DEFAULT_PORT instead of using g_strdup_printf().
> That avoids the memory leak.

Oops.

Do we have a macro for this already?  I couldn't see one, and the
best I could come up with is:

#define MACRO_EXPAND_STRINGIFY(x) STRINGIFY(x)
#define STRINGIFY(x) #x

static void setup_address_and_port(const char **address, const char **port)
{
    if (*address == NULL) {
        *address = "0.0.0.0";
    }

    if (*port == NULL) {
        *port = MACRO_EXPAND_STRINGIFY(NBD_DEFAULT_PORT);
    }
}

It works, but it's a bit of a mouthful.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v

  reply	other threads:[~2017-02-03 16:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-02 17:16 [Qemu-devel] [PATCH v2] qemu-nbd: Implement socket activation Richard W.M. Jones
2017-02-02 17:16 ` Richard W.M. Jones
2017-02-02 17:30   ` Daniel P. Berrange
2017-02-03 15:16   ` Stefan Hajnoczi
2017-02-03 16:52     ` Richard W.M. Jones [this message]
2017-02-04  9:58       ` Markus Armbruster

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=20170203165209.GZ15182@redhat.com \
    --to=rjones@redhat.com \
    --cc=berrange@redhat.com \
    --cc=den@openvz.org \
    --cc=dplotnikov@virtuozzo.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rkagan@virtuozzo.com \
    --cc=stefanha@gmail.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 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.