[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/40] chardev: use bool for fe_is_open
From: |
Alex Bennée |
Subject: |
[PATCH 04/40] chardev: use bool for fe_is_open |
Date: |
Thu, 21 Dec 2023 10:37:42 +0000 |
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>
---
v2
- rename to fe_is_open at f4bug's request
---
include/chardev/char-fe.h | 19 ++++++++++++-------
chardev/char-fe.c | 16 ++++++++--------
chardev/char.c | 2 +-
3 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h
index 0ff6f875116..ecef1828355 100644
--- a/include/chardev/char-fe.h
+++ b/include/chardev/char-fe.h
@@ -7,8 +7,12 @@
typedef void IOEventHandler(void *opaque, QEMUChrEvent event);
typedef int BackendChangeHandler(void *opaque);
-/* This is the backend as seen by frontend, the actual backend is
- * Chardev */
+/**
+ * struct CharBackend - back end as seen by front end
+ * @fe_is_open: the front end is ready for IO
+ *
+ * The actual backend is Chardev
+ */
struct CharBackend {
Chardev *chr;
IOEventHandler *chr_event;
@@ -17,7 +21,7 @@ struct CharBackend {
BackendChangeHandler *chr_be_change;
void *opaque;
int tag;
- int fe_open;
+ bool fe_is_open;
};
/**
@@ -156,12 +160,13 @@ void qemu_chr_fe_set_echo(CharBackend *be, bool echo);
/**
* qemu_chr_fe_set_open:
+ * @be: a CharBackend
+ * @is_open: the front end open status
*
- * Set character frontend open status. This is an indication that the
- * front end is ready (or not) to begin doing I/O.
- * Without associated Chardev, do nothing.
+ * This is an indication that the front end is ready (or not) to begin
+ * doing I/O. Without associated Chardev, do nothing.
*/
-void qemu_chr_fe_set_open(CharBackend *be, int fe_open);
+void qemu_chr_fe_set_open(CharBackend *be, bool is_open);
/**
* qemu_chr_fe_printf:
diff --git a/chardev/char-fe.c b/chardev/char-fe.c
index 7789f7be9c8..20222a4cad5 100644
--- a/chardev/char-fe.c
+++ b/chardev/char-fe.c
@@ -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);
}
}
diff --git a/chardev/char.c b/chardev/char.c
index 996a024c7a2..0653b112e92 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -750,7 +750,7 @@ static int qmp_query_chardev_foreach(Object *obj, void
*data)
value->label = g_strdup(chr->label);
value->filename = g_strdup(chr->filename);
- value->frontend_open = chr->be && chr->be->fe_open;
+ value->frontend_open = chr->be && chr->be->fe_is_open;
QAPI_LIST_PREPEND(*list, value);
--
2.39.2
- [PATCH 00/40] testing and plugin updates for 9.0, Alex Bennée, 2023/12/21
- [PATCH 02/40] tests/avocado: use snapshot=on in kvm_xen_guest, Alex Bennée, 2023/12/21
- [PATCH 05/40] qtest: bump min meson timeout to 60 seconds, Alex Bennée, 2023/12/21
- [PATCH 01/40] tests/avocado: Add a test for a little-endian microblaze machine, Alex Bennée, 2023/12/21
- [PATCH 06/40] qtest: bump migration-test timeout to 8 minutes, Alex Bennée, 2023/12/21
- [PATCH 03/40] gitlab: include microblazeel in testing, Alex Bennée, 2023/12/21
- [PATCH 10/40] qtest: bump pxe-test timeout to 10 minutes, Alex Bennée, 2023/12/21
- [PATCH 07/40] qtest: bump qom-test timeout to 15 minutes, Alex Bennée, 2023/12/21
- [PATCH 08/40] qtest: bump npcm7xx_pwn-test timeout to 5 minutes, Alex Bennée, 2023/12/21
- [PATCH 11/40] qtest: bump prom-env-test timeout to 6 minutes, Alex Bennée, 2023/12/21
- [PATCH 04/40] chardev: use bool for fe_is_open,
Alex Bennée <=
- [PATCH 14/40] qtest: bump aspeed_smc-test timeout to 6 minutes, Alex Bennée, 2023/12/21
- [PATCH 13/40] qtest: bump qos-test timeout to 2 minutes, Alex Bennée, 2023/12/21
- [PATCH 12/40] qtest: bump boot-serial-test timeout to 3 minutes, Alex Bennée, 2023/12/21
- [PATCH 19/40] tests/fp: Bump fp-test-mulAdd test timeout to 3 minutes, Alex Bennée, 2023/12/21
- [PATCH 15/40] qtest: bump bios-table-test timeout to 9 minutes, Alex Bennée, 2023/12/21
- [PATCH 09/40] qtest: bump test-hmp timeout to 4 minutes, Alex Bennée, 2023/12/21
- [PATCH 39/40] contrib/plugins: extend execlog to track register changes, Alex Bennée, 2023/12/21
- [PATCH 36/40] gdbstub: expose api to find registers, Alex Bennée, 2023/12/21
- [PATCH 37/40] plugins: add an API to read registers, Alex Bennée, 2023/12/21