[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks.
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks. |
Date: |
Thu, 13 Aug 2009 13:42:02 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) |
Gerd Hoffmann <address@hidden> writes:
> Hi,
>
>> I find stashing error messages for later printing rather awkward. Do
>> you provide space for one fixed-sized message? Or arbitrary length?
>> Arbitrary number of messages? Once you start to malloc(), you get to
>> worry about free()... Meh.
>
> Arbitrary length. See attached patch.
I just don't like filing diagnostics away in the hope that somebody up
the stack will remember to print them :)
At least, qemu_error_message needs to be thread-local.
>> I'd rather use the global or thread-local state to hold the sink for the
>> messages, then send the messages there as we make them. No memory
>> management worries.
>
> i.e. like config_error() in net.c? What I don't like there is that
> the error handling policy (monitor -> continue, otherwise exit) is in
> the error printing function. IMHO it is the job of the caller to
> decide how to handle an error (exit, ignore, pass up, whatever).
config_error() uses a Monitor * to encode what to do on error, which is
admittedly rather limiting. If you want to be more flexible, use (error
callback, argument). If you need a richer interface than that, define
an output object with suitable methods, say error, warning, information,
...
The difference to your patch is what the error object does.
With your patch:
call stuff (may accumulate messages in the output object)
flush output object down the appropriate sink
Alternative I'd prefer:
set up output object to point to the appropriate sink
call stuff (may print messages via output object to sink)
Look ma, no buffer management!
Output diversions are easy, too:
save output object
set up output object to point to the appropriate sink
call stuff (may print messages via output object to sink)
restore output object
- [Qemu-devel] [PATCH] qdev: add return value to init() callbacks., Gerd Hoffmann, 2009/08/12
- Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks., Markus Armbruster, 2009/08/12
- Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks., Paul Brook, 2009/08/12
- Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks., Gerd Hoffmann, 2009/08/12
- Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks., Markus Armbruster, 2009/08/13
- Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks., Gerd Hoffmann, 2009/08/13
- Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks., Markus Armbruster, 2009/08/13
- Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks., Gerd Hoffmann, 2009/08/13
- Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks.,
Markus Armbruster <=
- Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks., Gerd Hoffmann, 2009/08/13
- Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks., Markus Armbruster, 2009/08/13