Accordingly with recommendations in include/qapi/error.h accompany errp by boolean return value and get rid of error propagation.
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> Reviewed-by: Markus Armbruster <[email protected]> --- chardev/char.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 216c95c053..3e9a274d7d 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -246,14 +246,20 @@ int qemu_chr_add_client(Chardev *s, int fd) CHARDEV_GET_CLASS(s)->chr_add_client(s, fd) : -1; } -static void qemu_char_open(Chardev *chr, ChardevBackend *backend, +static bool qemu_char_open(Chardev *chr, ChardevBackend *backend, bool *be_opened, Error **errp) { + ERRP_GUARD(); ChardevClass *cc = CHARDEV_GET_CLASS(chr); if (cc->open) { cc->open(chr, backend, be_opened, errp); + if (*errp) { + return false; + } } + + return true; } static void char_init(Object *obj) @@ -1015,7 +1021,6 @@ static Chardev *chardev_new(const char *id, const char *typename, { Object *obj; Chardev *chr = NULL; - Error *local_err = NULL; bool be_opened = true; assert(g_str_has_prefix(typename, "chardev-")); @@ -1031,9 +1036,7 @@ static Chardev *chardev_new(const char *id, const char *typename, goto fail; } - qemu_char_open(chr, backend, &be_opened, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_char_open(chr, backend, &be_opened, errp)) { goto fail; } -- 2.48.1
