]> git.proxmox.com Git - mirror_qemu.git/commit - qga/commands-posix.c
qga: Clean up fragile use of error_is_set()
authorMarkus Armbruster <armbru@redhat.com>
Fri, 2 May 2014 11:26:38 +0000 (13:26 +0200)
committerLuiz Capitulino <lcapitulino@redhat.com>
Fri, 9 May 2014 13:11:31 +0000 (09:11 -0400)
commit0f230bf70eb9d74fe87df2a44bc7a69ed01ecbe3
treefd28bb9718d511062dfb9927b9fce4d5d5c9e4e6
parentee16ce93373dda1faa4aa1bb4d99bcdf158f7d7a
qga: Clean up fragile use of error_is_set()

Using error_is_set(ERRP) to find out whether a function failed is
either wrong, fragile, or unnecessarily opaque.  It's wrong when ERRP
may be null, because errors go undetected when it is.  It's fragile
when proving ERRP non-null involves a non-local argument.  Else, it's
unnecessarily opaque (see commit 84d18f0).

The error_is_set(errp) in the guest agent command handler functions
are merely fragile, because all chall chains (do_qmp_dispatch() via
the generated marshalling functions) pass a non-null errp argument.

Make the code more robust and more obviously correct: receive the
error in a local variable, then propagate it through the parameter.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
qga/commands-posix.c
qga/commands-win32.c