[PATCH-for-5.0,v3,3/6] hw/pci-host/i440fx: Use size_t to iterate over ARRAY_SIZE()
diff mbox series

Message ID 20191209095002.32194-4-philmd@redhat.com
State New
Headers show
Series
  • hw/pci-host: Add Kconfig selector for IGD PCIe pass-through
Related show

Commit Message

Philippe Mathieu-Daudé Dec. 9, 2019, 9:49 a.m. UTC
We don't enforce the -Wsign-conversion CPPFLAG, but it doesn't hurt
to avoid this warning:

  warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/pci-host/i440fx.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Thomas Huth Dec. 9, 2019, 10:05 a.m. UTC | #1
On 09/12/2019 10.49, Philippe Mathieu-Daudé wrote:
> We don't enforce the -Wsign-conversion CPPFLAG, but it doesn't hurt
> to avoid this warning:
> 
>   warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/pci-host/i440fx.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c
> index fbdc563599..0cc80b276d 100644
> --- a/hw/pci-host/i440fx.c
> +++ b/hw/pci-host/i440fx.c
> @@ -419,12 +419,11 @@ out:
>  static void igd_pt_i440fx_realize(PCIDevice *pci_dev, Error **errp)
>  {
>      uint32_t val = 0;
> -    int i, num;
> +    size_t i;
>      int pos, len;
>      Error *local_err = NULL;
>  
> -    num = ARRAY_SIZE(igd_host_bridge_infos);
> -    for (i = 0; i < num; i++) {
> +    for (i = 0; i < ARRAY_SIZE(igd_host_bridge_infos); i++) {
>          pos = igd_host_bridge_infos[i].offset;
>          len = igd_host_bridge_infos[i].len;
>          host_pci_config_read(pos, len, &val, &local_err);
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>
Laurent Vivier Dec. 18, 2019, 11:57 a.m. UTC | #2
Le 09/12/2019 à 11:05, Thomas Huth a écrit :
> On 09/12/2019 10.49, Philippe Mathieu-Daudé wrote:
>> We don't enforce the -Wsign-conversion CPPFLAG, but it doesn't hurt
>> to avoid this warning:
>>
>>   warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>  hw/pci-host/i440fx.c | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c
>> index fbdc563599..0cc80b276d 100644
>> --- a/hw/pci-host/i440fx.c
>> +++ b/hw/pci-host/i440fx.c
>> @@ -419,12 +419,11 @@ out:
>>  static void igd_pt_i440fx_realize(PCIDevice *pci_dev, Error **errp)
>>  {
>>      uint32_t val = 0;
>> -    int i, num;
>> +    size_t i;
>>      int pos, len;
>>      Error *local_err = NULL;
>>  
>> -    num = ARRAY_SIZE(igd_host_bridge_infos);
>> -    for (i = 0; i < num; i++) {
>> +    for (i = 0; i < ARRAY_SIZE(igd_host_bridge_infos); i++) {
>>          pos = igd_host_bridge_infos[i].offset;
>>          len = igd_host_bridge_infos[i].len;
>>          host_pci_config_read(pos, len, &val, &local_err);
>>
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> 
> 

Applied to my trivial-patches branch.

Thanks,
Laurent
Paolo Bonzini Dec. 18, 2019, 12:01 p.m. UTC | #3
On 18/12/19 12:57, Laurent Vivier wrote:
> Le 09/12/2019 à 11:05, Thomas Huth a écrit :
>> On 09/12/2019 10.49, Philippe Mathieu-Daudé wrote:
>>> We don't enforce the -Wsign-conversion CPPFLAG, but it doesn't hurt
>>> to avoid this warning:
>>>
>>>   warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>> ---
>>>  hw/pci-host/i440fx.c | 5 ++---
>>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c
>>> index fbdc563599..0cc80b276d 100644
>>> --- a/hw/pci-host/i440fx.c
>>> +++ b/hw/pci-host/i440fx.c
>>> @@ -419,12 +419,11 @@ out:
>>>  static void igd_pt_i440fx_realize(PCIDevice *pci_dev, Error **errp)
>>>  {
>>>      uint32_t val = 0;
>>> -    int i, num;
>>> +    size_t i;
>>>      int pos, len;
>>>      Error *local_err = NULL;
>>>  
>>> -    num = ARRAY_SIZE(igd_host_bridge_infos);
>>> -    for (i = 0; i < num; i++) {
>>> +    for (i = 0; i < ARRAY_SIZE(igd_host_bridge_infos); i++) {
>>>          pos = igd_host_bridge_infos[i].offset;
>>>          len = igd_host_bridge_infos[i].len;
>>>          host_pci_config_read(pos, len, &val, &local_err);
>>>
>>
>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>>
>>
> 
> Applied to my trivial-patches branch.

No need to, I've already queued the whole series.

Paolo
Laurent Vivier Dec. 18, 2019, 12:31 p.m. UTC | #4
Le 18/12/2019 à 13:01, Paolo Bonzini a écrit :
> On 18/12/19 12:57, Laurent Vivier wrote:
>> Le 09/12/2019 à 11:05, Thomas Huth a écrit :
>>> On 09/12/2019 10.49, Philippe Mathieu-Daudé wrote:
>>>> We don't enforce the -Wsign-conversion CPPFLAG, but it doesn't hurt
>>>> to avoid this warning:
>>>>
>>>>   warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
>>>>
>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>>> ---
>>>>  hw/pci-host/i440fx.c | 5 ++---
>>>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c
>>>> index fbdc563599..0cc80b276d 100644
>>>> --- a/hw/pci-host/i440fx.c
>>>> +++ b/hw/pci-host/i440fx.c
>>>> @@ -419,12 +419,11 @@ out:
>>>>  static void igd_pt_i440fx_realize(PCIDevice *pci_dev, Error **errp)
>>>>  {
>>>>      uint32_t val = 0;
>>>> -    int i, num;
>>>> +    size_t i;
>>>>      int pos, len;
>>>>      Error *local_err = NULL;
>>>>  
>>>> -    num = ARRAY_SIZE(igd_host_bridge_infos);
>>>> -    for (i = 0; i < num; i++) {
>>>> +    for (i = 0; i < ARRAY_SIZE(igd_host_bridge_infos); i++) {
>>>>          pos = igd_host_bridge_infos[i].offset;
>>>>          len = igd_host_bridge_infos[i].len;
>>>>          host_pci_config_read(pos, len, &val, &local_err);
>>>>
>>>
>>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>>>
>>>
>>
>> Applied to my trivial-patches branch.
> 
> No need to, I've already queued the whole series.
> 

ok, I've removed them from my queue.

Thanks,
Laurent

Patch
diff mbox series

diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c
index fbdc563599..0cc80b276d 100644
--- a/hw/pci-host/i440fx.c
+++ b/hw/pci-host/i440fx.c
@@ -419,12 +419,11 @@  out:
 static void igd_pt_i440fx_realize(PCIDevice *pci_dev, Error **errp)
 {
     uint32_t val = 0;
-    int i, num;
+    size_t i;
     int pos, len;
     Error *local_err = NULL;
 
-    num = ARRAY_SIZE(igd_host_bridge_infos);
-    for (i = 0; i < num; i++) {
+    for (i = 0; i < ARRAY_SIZE(igd_host_bridge_infos); i++) {
         pos = igd_host_bridge_infos[i].offset;
         len = igd_host_bridge_infos[i].len;
         host_pci_config_read(pos, len, &val, &local_err);