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

Re: [Nbd] [PATCH] nbd-server: replace msg2(), msg3() and msg4() with variadic msg()



On Fri, Dec 28, 2012 at 11:33:00PM +0200, Tuomas Jorma Juhani Räsänen wrote:
> 
> Signed-off-by: Tuomas Jorma Juhani Räsänen <tuomasjjrasanen@...1261...>
> ---
>  nbd-server.c |   64 ++++++++++++++++++++++++++++++----------------------------
>  1 file changed, 33 insertions(+), 31 deletions(-)
> 
> diff --git a/nbd-server.c b/nbd-server.c
> index ec617a9..3c8dc9d 100644
> --- a/nbd-server.c
> +++ b/nbd-server.c
> @@ -126,16 +126,18 @@ int glob_flags=0;
>  /* Whether we should avoid forking */
>  int dontfork = 0;
>  
> +static void msg(const int priority, const char *const format, ...) {
> +        va_list ap;
> +
> +        va_start(ap, format);
>  /** Logging macros, now nothing goes to syslog unless you say ISSERVER */
>  #ifdef ISSERVER
> -#define msg2(a,b) syslog(a,b)
> -#define msg3(a,b,c) syslog(a,b,c)
> -#define msg4(a,b,c,d) syslog(a,b,c,d)
> +        vsyslog(priority, format, ap);
>  #else
> -#define msg2(a,b) g_message((char*)b)
> -#define msg3(a,b,c) g_message((char*)b,c)
> -#define msg4(a,b,c,d) g_message((char*)b,c,d)
> +        g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, ap);
>  #endif
> +        va_end(ap);
> +}

I've applied this too, but after I did so and pushed it I started
thinking that, because it really only calls one function, it might be
better, for now, to use a C99-style variadic macro instead. I've changed
it in that way.

-- 
Copyshops should do vouchers. So that next time some bureaucracy requires you
to mail a form in triplicate, you can mail it just once, add a voucher, and
save on postage.



Reply to: