"Richard W.M. Jones" <rjo...@redhat.com> writes: > 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
Check out stringify() in compiler.h. (Yes, lower-case macros that don't behave like functions are bad style) [...]