It is futile to call qemu_chr_fe_set_handlers() without an associated chardev, because the function is doing nothing in that case, not even reporting an error, it would likely be a programming error. Let's not handle that hypothetical case.
(fwiw, I introduced the check in commit 94a40fc56036b5058b0b194d9e372a22e65ce7be, that was a mistake imho) Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- include/chardev/char-fe.h | 2 -- chardev/char-fe.c | 7 +------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h index 46c997d352..54f0d61d32 100644 --- a/include/chardev/char-fe.h +++ b/include/chardev/char-fe.h @@ -82,8 +82,6 @@ bool qemu_chr_fe_backend_open(CharBackend *be); * * Set the front end char handlers. The front end takes the focus if * any of the handler is non-NULL. - * - * Without associated Chardev, nothing is changed. */ void qemu_chr_fe_set_handlers(CharBackend *b, IOCanReadHandler *fd_can_read, diff --git a/chardev/char-fe.c b/chardev/char-fe.c index f69ca18647..4ec9823d34 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -255,14 +255,9 @@ void qemu_chr_fe_set_handlers(CharBackend *b, GMainContext *context, bool set_open) { - Chardev *s; + Chardev *s = b->chr; int fe_open; - s = b->chr; - if (!s) { - return; - } - if (!opaque && !fd_can_read && !fd_read && !fd_event) { fe_open = 0; remove_fd_in_watch(s); -- 2.20.1.519.g8feddda32c