Skip to contentSkip to conversation

error reporting in functions

Qemu-devel Vladimir Sementsov-Ogievskiy 3 participants 3 messages Oct 12, 2016 – Oct 13, 2016

lore
Share & tools
lore
#0 lore raw

HI all!

My questions is: what are general recommendations in Qemu for return code, if we have Error **errp? What should I prefer: errp, duplicated by int return code, or void functions with errp?

void + errp seems good, just to not duplicate things. But it has a disadvantage of necessity of "local_err" and "error_propagate" in caller function, if its behaviour depends on callee function success...

Signature · 2 lines
Best regards,
Vladimir
#1 lore raw
Quoted 6 lines · Vladimir Sementsov-Ogievskiy

HI all!

My questions is: what are general recommendations in Qemu for return code, if we have Error **errp?
What should I prefer: errp, duplicated by int return code, or void functions with errp?

Markus has already had several threads commenting on this very topic in the past. A lot of code uses void return, but some newer code is using an int return for simplifying the call-sites (and glib prefers the int rather than void return, as well). Markus was playing with a Coccinelle script to see how painful a bulk-conversion of the code base would be, but it is probably stalled behind more pressing work at the moment.

Quoted 5 lines

void + errp seems good, just to not duplicate things. But it has a disadvantage of necessity of "local_err" and "error_propagate" in caller function, if its behaviour depends on callee function success...

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
Quoted 10 lines · Eric Blake
Quoted 6 lines · Vladimir Sementsov-Ogievskiy

HI all!

My questions is: what are general recommendations in Qemu for return code, if we have Error **errp?
What should I prefer: errp, duplicated by int return code, or void functions with errp?

Markus has already had several threads commenting on this very topic in the past. A lot of code uses void return, but some newer code is using

A recent one:
Message-ID: <[email protected]>
http://lists.gnu.org/archive/html/qemu-devel/2016-10/msg00435.html

Quoted 5 lines

the past. A lot of code uses void return, but some newer code is using an int return for simplifying the call-sites (and glib prefers the int rather than void return, as well). Markus was playing with a Coccinelle script to see how painful a bulk-conversion of the code base would be, but it is probably stalled behind more pressing work at the moment.

Correct.

Quoted 3 lines
Quoted 3 lines

void + errp seems good, just to not duplicate things. But it has a disadvantage of necessity of "local_err" and "error_propagate" in caller function, if its behaviour depends on callee function success...