[cc: kraxel]

Jan Kiszka <jan.kis...@web.de> writes:

> From: Jan Kiszka <jan.kis...@siemens.com>
>
> Path abbreviations suffer from the inconsistency that bus names can only
> be omitted at the end of a path. Drop this special rule, and also remove
> the now obsolete QERR_DEVICE_MULTIPLE_BUSSES.
>
> Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

Affects only -device and device_add option bus.  I support this.

> ---
>  hw/qdev.c |   22 ++++------------------
>  qerror.c  |    4 ----
>  qerror.h  |    3 ---
>  3 files changed, 4 insertions(+), 25 deletions(-)
>
> diff --git a/hw/qdev.c b/hw/qdev.c
> index 61f999c..7c4f039 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -608,32 +608,18 @@ static BusState *qbus_find(const char *path)
>              }
>              return NULL;
>          }
> +        if (dev->num_child_bus == 0) {
> +            qerror_report(QERR_DEVICE_NO_BUS, elem);
> +            return NULL;
> +        }

I'd kill this check as well.  The QERR_BUS_NOT_FOUND further down
suffices.

>  
>          assert(path[pos] == '/' || !path[pos]);
>          while (path[pos] == '/') {
>              pos++;
>          }
> -        if (path[pos] == '\0') {
> -            /* last specified element is a device.  If it has exactly
> -             * one child bus accept it nevertheless */
> -            switch (dev->num_child_bus) {
> -            case 0:
> -                qerror_report(QERR_DEVICE_NO_BUS, elem);
> -                return NULL;
> -            case 1:
> -                return QLIST_FIRST(&dev->child_bus);
> -            default:
> -                qerror_report(QERR_DEVICE_MULTIPLE_BUSSES, elem);
> -                if (!monitor_cur_is_qmp()) {
> -                    qbus_list_bus(dev);
> -                }
> -                return NULL;
> -            }
> -        }
>  
>          /* find bus */
>          if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) {
> -            assert(0);
>              elem[0] = len = 0;
>          }
>          pos += len;
[...]

Reply via email to