qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] qemu-nbd: Implement socket activation.


From: Richard W.M. Jones
Subject: Re: [Qemu-devel] [PATCH v2] qemu-nbd: Implement socket activation.
Date: Fri, 3 Feb 2017 16:52:09 +0000
User-agent: Mutt/1.5.20 (2009-12-10)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]