mirror of https://gitee.com/openkylin/qemu.git
char: Simplify chardev_name_foreach()
Both callers use callbacks that don't do anything when they are called for CLI aliases. Instead of passing the cli_alias parameter, just don't call the callbacks for aliases in the first place. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20210311164253.338723-4-kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
5965243641
commit
f3b70e0779
|
@ -548,7 +548,7 @@ static struct ChardevAlias {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct ChadevClassFE {
|
typedef struct ChadevClassFE {
|
||||||
void (*fn)(const char *name, bool is_cli_alias, void *opaque);
|
void (*fn)(const char *name, void *opaque);
|
||||||
void *opaque;
|
void *opaque;
|
||||||
} ChadevClassFE;
|
} ChadevClassFE;
|
||||||
|
|
||||||
|
@ -562,33 +562,23 @@ chardev_class_foreach(ObjectClass *klass, void *opaque)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fe->fn(object_class_get_name(klass) + 8, false, fe->opaque);
|
fe->fn(object_class_get_name(klass) + 8, fe->opaque);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
chardev_name_foreach(void (*fn)(const char *name, bool is_cli_alias,
|
chardev_name_foreach(void (*fn)(const char *name, void *opaque),
|
||||||
void *opaque),
|
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
ChadevClassFE fe = { .fn = fn, .opaque = opaque };
|
ChadevClassFE fe = { .fn = fn, .opaque = opaque };
|
||||||
int i;
|
|
||||||
|
|
||||||
object_class_foreach(chardev_class_foreach, TYPE_CHARDEV, false, &fe);
|
object_class_foreach(chardev_class_foreach, TYPE_CHARDEV, false, &fe);
|
||||||
|
|
||||||
for (i = 0; i < (int)ARRAY_SIZE(chardev_alias_table); i++) {
|
|
||||||
fn(chardev_alias_table[i].alias, true, opaque);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
help_string_append(const char *name, bool is_cli_alias, void *opaque)
|
help_string_append(const char *name, void *opaque)
|
||||||
{
|
{
|
||||||
GString *str = opaque;
|
GString *str = opaque;
|
||||||
|
|
||||||
if (is_cli_alias) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_string_append_printf(str, "\n %s", name);
|
g_string_append_printf(str, "\n %s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,15 +800,11 @@ ChardevInfoList *qmp_query_chardev(Error **errp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
qmp_prepend_backend(const char *name, bool is_cli_alias, void *opaque)
|
qmp_prepend_backend(const char *name, void *opaque)
|
||||||
{
|
{
|
||||||
ChardevBackendInfoList **list = opaque;
|
ChardevBackendInfoList **list = opaque;
|
||||||
ChardevBackendInfo *value;
|
ChardevBackendInfo *value;
|
||||||
|
|
||||||
if (is_cli_alias) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = g_new0(ChardevBackendInfo, 1);
|
value = g_new0(ChardevBackendInfo, 1);
|
||||||
value->name = g_strdup(name);
|
value->name = g_strdup(name);
|
||||||
QAPI_LIST_PREPEND(*list, value);
|
QAPI_LIST_PREPEND(*list, value);
|
||||||
|
|
Loading…
Reference in New Issue