chardev: use bool for fe_is_open

The function qemu_chr_fe_init already treats be->fe_open as a bool and
if it acts like a bool it should be one. While we are at it make the
variable name more descriptive and add kdoc decorations.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20231211145959.93759-1-alex.bennee@linaro.org>
This commit is contained in:
Alex Bennée 2023-12-11 14:59:59 +00:00
parent 2d41bf0fe1
commit 67b5595d3b
3 changed files with 21 additions and 16 deletions

View file

@ -211,7 +211,7 @@ bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp)
}
}
b->fe_open = false;
b->fe_is_open = false;
b->tag = tag;
b->chr = s;
return true;
@ -257,7 +257,7 @@ void qemu_chr_fe_set_handlers_full(CharBackend *b,
bool sync_state)
{
Chardev *s;
int fe_open;
bool fe_open;
s = b->chr;
if (!s) {
@ -265,10 +265,10 @@ void qemu_chr_fe_set_handlers_full(CharBackend *b,
}
if (!opaque && !fd_can_read && !fd_read && !fd_event) {
fe_open = 0;
fe_open = false;
remove_fd_in_watch(s);
} else {
fe_open = 1;
fe_open = true;
}
b->chr_can_read = fd_can_read;
b->chr_read = fd_read;
@ -336,7 +336,7 @@ void qemu_chr_fe_set_echo(CharBackend *be, bool echo)
}
}
void qemu_chr_fe_set_open(CharBackend *be, int fe_open)
void qemu_chr_fe_set_open(CharBackend *be, bool is_open)
{
Chardev *chr = be->chr;
@ -344,12 +344,12 @@ void qemu_chr_fe_set_open(CharBackend *be, int fe_open)
return;
}
if (be->fe_open == fe_open) {
if (be->fe_is_open == is_open) {
return;
}
be->fe_open = fe_open;
be->fe_is_open = is_open;
if (CHARDEV_GET_CLASS(chr)->chr_set_fe_open) {
CHARDEV_GET_CLASS(chr)->chr_set_fe_open(chr, fe_open);
CHARDEV_GET_CLASS(chr)->chr_set_fe_open(chr, is_open);
}
}