In the following patches `MuxChardev` struct will suport backend
multiplexing, the `mux_cnt` struct member has very common name
and does not reflect the actual meaning: number of frontends
attached to a mux. This patch renames the `mux_cnt` to `fe_cnt`.
No other functional changes made.
Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org
---
chardev/char-fe.c | 7 +++----
chardev/char-mux.c | 12 ++++++------
chardev/char.c | 2 +-
chardev/chardev-internal.h | 2 +-
4 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/chardev/char-fe.c b/chardev/char-fe.c
index b214ba3802b1..e6f44801162a 100644
--- a/chardev/char-fe.c
+++ b/chardev/char-fe.c
@@ -197,16 +197,15 @@ bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp)
if (CHARDEV_IS_MUX(s)) {
MuxChardev *d = MUX_CHARDEV(s);
- if (d->mux_cnt >= MAX_MUX) {
+ if (d->fe_cnt >= MAX_MUX) {
error_setg(errp,
"too many uses of multiplexed chardev '%s'"
" (maximum is " stringify(MAX_MUX) ")",
s->label);
return false;
}
-
- d->backends[d->mux_cnt] = b;
- tag = d->mux_cnt++;
+ d->backends[d->fe_cnt] = b;
+ tag = d->fe_cnt++;
} else if (s->be) {
error_setg(errp, "chardev '%s' is already in use", s->label);
return false;
diff --git a/chardev/char-mux.c b/chardev/char-mux.c
index ee2d47b20d9b..eb72b3cdb80b 100644
--- a/chardev/char-mux.c
+++ b/chardev/char-mux.c
@@ -168,9 +168,9 @@ static int mux_proc_byte(Chardev *chr, MuxChardev *d, int ch)
qemu_chr_be_event(chr, CHR_EVENT_BREAK);
break;
case 'c':
- assert(d->mux_cnt > 0); /* handler registered with first fe */
+ assert(d->fe_cnt > 0); /* handler registered with first fe */
/* Switch to the next registered device */
- mux_set_focus(chr, (d->focus + 1) % d->mux_cnt);
+ mux_set_focus(chr, (d->focus + 1) % d->fe_cnt);
break;
case 't':
d->timestamps = !d->timestamps;
@@ -248,8 +248,8 @@ void mux_chr_send_all_event(Chardev *chr, QEMUChrEvent event)
return;
}
- /* Send the event to all registered listeners */
- for (i = 0; i < d->mux_cnt; i++) {
+ /* Send the event to all registered frontend listeners */
+ for (i = 0; i < d->fe_cnt; i++) {
mux_chr_send_event(d, i, event);
}
}
@@ -277,7 +277,7 @@ static void char_mux_finalize(Object *obj)
MuxChardev *d = MUX_CHARDEV(obj);
int i;
- for (i = 0; i < d->mux_cnt; i++) {
+ for (i = 0; i < d->fe_cnt; i++) {
CharBackend *be = d->backends[i];
if (be) {
be->chr = NULL;
@@ -305,7 +305,7 @@ void mux_set_focus(Chardev *chr, int focus)
MuxChardev *d = MUX_CHARDEV(chr);
assert(focus >= 0);
- assert(focus < d->mux_cnt);
+ assert(focus < d->fe_cnt);
if (d->focus != -1) {
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_OUT);
diff --git a/chardev/char.c b/chardev/char.c
index 4b3e45b2a128..3f0fcc8b16f6 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -333,7 +333,7 @@ static bool qemu_chr_is_busy(Chardev *s)
{
if (CHARDEV_IS_MUX(s)) {
MuxChardev *d = MUX_CHARDEV(s);
- return d->mux_cnt >= 0;
+ return d->fe_cnt >= 0;
} else {
return s->be != NULL;
}
diff --git a/chardev/chardev-internal.h b/chardev/chardev-internal.h
index 4e03af31476c..e8c3c29d1a59 100644
--- a/chardev/chardev-internal.h
+++ b/chardev/chardev-internal.h
@@ -38,7 +38,7 @@ struct MuxChardev {
CharBackend *backends[MAX_MUX];
CharBackend chr;
int focus;
- int mux_cnt;
+ int fe_cnt;
int term_got_escape;
int max_size;
/* Intermediate input buffer catches escape sequences even if the
--
2.43.0