diff mbox

[qemu] pci: Initialize pci_dev->name before use

Message ID 20170825032101.42538-1-aik@ozlabs.ru
State New
Headers show

Commit Message

Alexey Kardashevskiy Aug. 25, 2017, 3:21 a.m. UTC
This moves pci_dev->name initialization earlier so
pci_dev->bus_master_as could get a name instead of empry string.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 hw/pci/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé Aug. 25, 2017, 12:09 p.m. UTC | #1
On 08/25/2017 12:21 AM, Alexey Kardashevskiy wrote:
> This moves pci_dev->name initialization earlier so
> pci_dev->bus_master_as could get a name instead of empry string.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   hw/pci/pci.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 258fbe51e2..852babe812 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -1000,6 +1000,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>   
>       pci_dev->devfn = devfn;
>       pci_dev->requester_id_cache = pci_req_id_cache_get(pci_dev);
> +    pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
>   
>       memory_region_init(&pci_dev->bus_master_container_region, OBJECT(pci_dev),
>                          "bus master container", UINT64_MAX);
> @@ -1009,7 +1010,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>       if (qdev_hotplug) {
>           pci_init_bus_master(pci_dev);
>       }
> -    pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
>       pci_dev->irq_state = 0;
>       pci_config_alloc(pci_dev);
>   
>
Eric Blake Aug. 25, 2017, 3:25 p.m. UTC | #2
On 08/24/2017 10:21 PM, Alexey Kardashevskiy wrote:
> This moves pci_dev->name initialization earlier so
> pci_dev->bus_master_as could get a name instead of empry string.

s/empry/an empty/

> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
diff mbox

Patch

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 258fbe51e2..852babe812 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1000,6 +1000,7 @@  static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
 
     pci_dev->devfn = devfn;
     pci_dev->requester_id_cache = pci_req_id_cache_get(pci_dev);
+    pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
 
     memory_region_init(&pci_dev->bus_master_container_region, OBJECT(pci_dev),
                        "bus master container", UINT64_MAX);
@@ -1009,7 +1010,6 @@  static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
     if (qdev_hotplug) {
         pci_init_bus_master(pci_dev);
     }
-    pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
     pci_dev->irq_state = 0;
     pci_config_alloc(pci_dev);