mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
error: Fix use of error_prepend() with &error_fatal, &error_abort
From include/qapi/error.h: * Pass an existing error to the caller with the message modified: * error_propagate(errp, err); * error_prepend(errp, "Could not frobnicate '%s': ", name); Fei Li pointed out that doing error_propagate() first doesn't work well when @errp is &error_fatal or &error_abort: the error_prepend() is never reached. Since I doubt fixing the documentation will stop people from getting it wrong, introduce error_propagate_prepend(), in the hope that it lures people away from using its constituents in the wrong order. Update the instructions in error.h accordingly. Convert existing error_prepend() next to error_propagate to error_propagate_prepend(). If any of these get reached with &error_fatal or &error_abort, the error messages improve. I didn't check whether that's the case anywhere. Cc: Fei Li <fli@suse.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20181017082702.5581-2-armbru@redhat.com>
This commit is contained in:
parent
d7ecf71238
commit
4b5766488f
13 changed files with 61 additions and 33 deletions
|
@ -320,8 +320,9 @@ static void icp_realize(DeviceState *dev, Error **errp)
|
|||
|
||||
obj = object_property_get_link(OBJECT(dev), ICP_PROP_XICS, &err);
|
||||
if (!obj) {
|
||||
error_propagate(errp, err);
|
||||
error_prepend(errp, "required link '" ICP_PROP_XICS "' not found: ");
|
||||
error_propagate_prepend(errp, err,
|
||||
"required link '" ICP_PROP_XICS
|
||||
"' not found: ");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -329,8 +330,9 @@ static void icp_realize(DeviceState *dev, Error **errp)
|
|||
|
||||
obj = object_property_get_link(OBJECT(dev), ICP_PROP_CPU, &err);
|
||||
if (!obj) {
|
||||
error_propagate(errp, err);
|
||||
error_prepend(errp, "required link '" ICP_PROP_CPU "' not found: ");
|
||||
error_propagate_prepend(errp, err,
|
||||
"required link '" ICP_PROP_CPU
|
||||
"' not found: ");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -624,8 +626,9 @@ static void ics_base_realize(DeviceState *dev, Error **errp)
|
|||
|
||||
obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &err);
|
||||
if (!obj) {
|
||||
error_propagate(errp, err);
|
||||
error_prepend(errp, "required link '" ICS_PROP_XICS "' not found: ");
|
||||
error_propagate_prepend(errp, err,
|
||||
"required link '" ICS_PROP_XICS
|
||||
"' not found: ");
|
||||
return;
|
||||
}
|
||||
ics->xics = XICS_FABRIC(obj);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue