mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
qdev: Hide "ptr" properties from users
Users can't set them, so qdev_device_help() shouldn't list them. Fix that. Also make qdev_prop_parse() hide them instead of printing a meaningless "has no parser" error message. Their value means nothing to users, so qdev_print_props() shouldn't print it. Fix by removing their print method. Their only use is dirty hacks. Document that.
This commit is contained in:
parent
c64eafaf0c
commit
036f7166c7
2 changed files with 23 additions and 13 deletions
|
@ -402,17 +402,11 @@ PropertyInfo qdev_prop_vlan = {
|
|||
|
||||
/* --- pointer --- */
|
||||
|
||||
static int print_ptr(DeviceState *dev, Property *prop, char *dest, size_t len)
|
||||
{
|
||||
void **ptr = qdev_get_prop_ptr(dev, prop);
|
||||
return snprintf(dest, len, "<%p>", *ptr);
|
||||
}
|
||||
|
||||
/* Not a proper property, just for dirty hacks. TODO Remove it! */
|
||||
PropertyInfo qdev_prop_ptr = {
|
||||
.name = "ptr",
|
||||
.type = PROP_TYPE_PTR,
|
||||
.size = sizeof(void*),
|
||||
.print = print_ptr,
|
||||
};
|
||||
|
||||
/* --- mac address --- */
|
||||
|
@ -547,16 +541,17 @@ int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
|
|||
int ret;
|
||||
|
||||
prop = qdev_prop_find(dev, name);
|
||||
if (!prop) {
|
||||
/*
|
||||
* TODO Properties without a parse method are just for dirty
|
||||
* hacks. qdev_prop_ptr is the only such PropertyInfo. It's
|
||||
* marked for removal. The test !prop->info->parse should be
|
||||
* removed along with it.
|
||||
*/
|
||||
if (!prop || !prop->info->parse) {
|
||||
fprintf(stderr, "property \"%s.%s\" not found\n",
|
||||
dev->info->name, name);
|
||||
return -1;
|
||||
}
|
||||
if (!prop->info->parse) {
|
||||
fprintf(stderr, "property \"%s.%s\" has no parser\n",
|
||||
dev->info->name, name);
|
||||
return -1;
|
||||
}
|
||||
ret = prop->info->parse(dev, prop, value);
|
||||
if (ret < 0) {
|
||||
switch (ret) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue