[libvirt] [PATCH 04/18] virpcimock: Drop needless typecast

Michal Privoznik posted 18 patches 6 years, 5 months ago
[libvirt] [PATCH 04/18] virpcimock: Drop needless typecast
Posted by Michal Privoznik 6 years, 5 months ago
When creating a PCI device, the pciDevice structure contains @id
member which holds device address (DDDD.BB:DD.F) and is type of
'char *'. But the structure is initialized from a const char and
in fact we never modify or free the @id.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tests/virpcimock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 1c21e4e045..853ac588e9 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -120,7 +120,7 @@ struct pciDriver {
 };
 
 struct pciDevice {
-    char *id;
+    const char *id;
     int vendor;
     int device;
     int klass;
@@ -878,7 +878,7 @@ init_env(void)
 
 # define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \
     do { \
-        struct pciDevice dev = {.id = (char *)Id, .vendor = Vendor, \
+        struct pciDevice dev = {.id = Id, .vendor = Vendor, \
                                 .device = Device, __VA_ARGS__}; \
         pci_device_new_from_stub(&dev); \
     } while (0)
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 04/18] virpcimock: Drop needless typecast
Posted by Daniel Henrique Barboza 6 years, 5 months ago
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>

On 8/14/19 8:57 AM, Michal Privoznik wrote:
> When creating a PCI device, the pciDevice structure contains @id
> member which holds device address (DDDD.BB:DD.F) and is type of
> 'char *'. But the structure is initialized from a const char and
> in fact we never modify or free the @id.
>
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>   tests/virpcimock.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/virpcimock.c b/tests/virpcimock.c
> index 1c21e4e045..853ac588e9 100644
> --- a/tests/virpcimock.c
> +++ b/tests/virpcimock.c
> @@ -120,7 +120,7 @@ struct pciDriver {
>   };
>   
>   struct pciDevice {
> -    char *id;
> +    const char *id;
>       int vendor;
>       int device;
>       int klass;
> @@ -878,7 +878,7 @@ init_env(void)
>   
>   # define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \
>       do { \
> -        struct pciDevice dev = {.id = (char *)Id, .vendor = Vendor, \
> +        struct pciDevice dev = {.id = Id, .vendor = Vendor, \
>                                   .device = Device, __VA_ARGS__}; \
>           pci_device_new_from_stub(&dev); \
>       } while (0)

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list