[Top][All Lists]
[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
[Qemu-devel] [PATCH 02/18] qemu-sockets: add Error ** to all functions, Paolo Bonzini, 2012/10/03
[Qemu-devel] [PATCH 03/18] qemu-sockets: unix_listen and unix_connect are portable, Paolo Bonzini, 2012/10/03
[Qemu-devel] [PATCH 05/18] migration: avoid using error_is_set, Paolo Bonzini, 2012/10/03