qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 01/18] error: add error_set_errno and error_setg


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 01/18] error: add error_set_errno and error_setg_errno
Date: Wed, 17 Oct 2012 15:03:44 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121009 Thunderbird/16.0

Il 17/10/2012 14:56, Markus Armbruster ha scritto:
> Duplicates error_set() code without need.  How about:
> 
> void error_set_errno(Error **errp, int os_errno, ErrorClass err_class,
>                      const char *fmt, ...)
> {
>     char *msg;
> 
>     va_start(ap, fmt);
>     msg = g_strdup_printf(fmt, ap);
>     va_end(ap);
>     if (os_errno) {
>         error_set(errp, err_class, "%s: %s", msg, strerror(os_errno));
>     } else {
>         error_set(errp, err_class, "%s", msg);
>     }
>     g_free(msg);
> }
> 
> Sketch, not even compile-tested.
> 
> Or the other way round, implement error_set() in terms of the more
> general error_set_errno():
> 
> void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...)
> {
>     error_set(errp, err_class, 0, fmt, ...);
> }
> 
> Except that's not C; real code needs verror_set_errno().
> 
> As usual, every variadic function sooner or later needs a buddy that
> takes a va_list instead.

Indeed... lazy me.

Added to my todo list.

Paolo




reply via email to

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