* [Qemu-devel] [PATCH 1/1] qdev: rename qdev_create() argument to sync with qdev_try_create()
@ 2018-12-24 6:35 Dongli Zhang
2019-01-08 12:38 ` Markus Armbruster
0 siblings, 1 reply; 2+ messages in thread
From: Dongli Zhang @ 2018-12-24 6:35 UTC (permalink / raw)
To: qemu-trivial, qemu-devel; +Cc: laurent, mjt, armbru
The second argument used by qdev_create() is typename and 'name' is very
confusing. Rename it from 'name' to 'type', which is the same used by
qdev_try_create().
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
hw/core/qdev.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 6b3cc55..1d65e8f 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -113,17 +113,17 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
/* Create a new device. This only initializes the device state
structure and allows properties to be set. The device still needs
to be realized. See qdev-core.h. */
-DeviceState *qdev_create(BusState *bus, const char *name)
+DeviceState *qdev_create(BusState *bus, const char *type)
{
DeviceState *dev;
- dev = qdev_try_create(bus, name);
+ dev = qdev_try_create(bus, type);
if (!dev) {
if (bus) {
- error_report("Unknown device '%s' for bus '%s'", name,
+ error_report("Unknown device '%s' for bus '%s'", type,
object_get_typename(OBJECT(bus)));
} else {
- error_report("Unknown device '%s' for default sysbus", name);
+ error_report("Unknown device '%s' for default sysbus", type);
}
abort();
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH 1/1] qdev: rename qdev_create() argument to sync with qdev_try_create()
2018-12-24 6:35 [Qemu-devel] [PATCH 1/1] qdev: rename qdev_create() argument to sync with qdev_try_create() Dongli Zhang
@ 2019-01-08 12:38 ` Markus Armbruster
0 siblings, 0 replies; 2+ messages in thread
From: Markus Armbruster @ 2019-01-08 12:38 UTC (permalink / raw)
To: Dongli Zhang
Cc: qemu-trivial, qemu-devel, mjt, laurent,
Philippe Mathieu-Daudé, Paolo Bonzini
Dongli Zhang <dongli.zhang@oracle.com> writes:
> The second argument used by qdev_create() is typename and 'name' is very
> confusing. Rename it from 'name' to 'type', which is the same used by
> qdev_try_create().
>
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> ---
> hw/core/qdev.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 6b3cc55..1d65e8f 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -113,17 +113,17 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
> /* Create a new device. This only initializes the device state
> structure and allows properties to be set. The device still needs
> to be realized. See qdev-core.h. */
> -DeviceState *qdev_create(BusState *bus, const char *name)
> +DeviceState *qdev_create(BusState *bus, const char *type)
> {
> DeviceState *dev;
>
> - dev = qdev_try_create(bus, name);
> + dev = qdev_try_create(bus, type);
> if (!dev) {
> if (bus) {
> - error_report("Unknown device '%s' for bus '%s'", name,
> + error_report("Unknown device '%s' for bus '%s'", type,
> object_get_typename(OBJECT(bus)));
> } else {
> - error_report("Unknown device '%s' for default sysbus", name);
> + error_report("Unknown device '%s' for default sysbus", type);
> }
> abort();
> }
Yes, @name is rather generic. The sub-par function comment doesn't
really help.
You rename the parameter in the definition, but not in the declaration
(qdev-core.h). Better keep them consistent.
Note that qdev_create() is just one instance of the "variables
containing type names are confusingly named" pattern. Let's start with
just qdev-core.h:
* qdev_create() parameter @name.
* qdev_try_create() parameter @name. The definition in qdev.c calls it
@type.
* qbus_create_inplace() parameter @typename.
* qbus_create() parameter @typename. The definition in bus.c calls it
@name.
Let's pick a single identifier and use it consistently. Picking
@typename would minimize churn, and be consistent with object_new() &
friends. Philippe, Paolo, what do you think?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-08 12:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-24 6:35 [Qemu-devel] [PATCH 1/1] qdev: rename qdev_create() argument to sync with qdev_try_create() Dongli Zhang
2019-01-08 12:38 ` Markus Armbruster
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).