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]> --- chardev/char.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index bdd907f015..fadbda5907 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -246,7 +246,7 @@ 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, Error **errp) +static bool qemu_char_open(Chardev *chr, ChardevBackend *backend, Error **errp) { ChardevClass *cc = CHARDEV_GET_CLASS(chr); /* Any ChardevCommon member would work */ @@ -262,13 +262,15 @@ static void qemu_char_open(Chardev *chr, ChardevBackend *backend, Error **errp) } chr->logfd = qemu_create(common->logfile, flags, 0666, errp); if (chr->logfd < 0) { - return; + return false; } } - if (cc->chr_open) { - cc->chr_open(chr, backend, errp); + if (cc->chr_open && !cc->chr_open(chr, backend, errp)) { + return false; } + + return true; } static void char_init(Object *obj) @@ -1007,7 +1009,6 @@ static Chardev *chardev_new(const char *id, const char *typename, { Object *obj; Chardev *chr = NULL; - Error *local_err = NULL; assert(g_str_has_prefix(typename, "chardev-")); assert(id); @@ -1018,9 +1019,7 @@ static Chardev *chardev_new(const char *id, const char *typename, chr->label = g_strdup(id); chr->gcontext = gcontext; - qemu_char_open(chr, backend, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_char_open(chr, backend, errp)) { object_unref(obj); return NULL; } -- 2.48.1
