qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow
@ 2023-10-04 11:48 Thomas Huth
  2023-10-04 12:51 ` Michael S. Tsirkin
  2023-10-06  6:26 ` Michael Tokarev
  0 siblings, 2 replies; 10+ messages in thread
From: Thomas Huth @ 2023-10-04 11:48 UTC (permalink / raw)
  To: qemu-devel, Michael S. Tsirkin; +Cc: Markus Armbruster, qemu-trivial

Rename a variable in vhost_dev_sync_region() and remove a superfluous
declaration in vhost_commit() to make this code compilable with "-Wshadow".

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/virtio/vhost.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index e2f6ffb446..9cfac40fde 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -66,12 +66,12 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
                                   uint64_t mfirst, uint64_t mlast,
                                   uint64_t rfirst, uint64_t rlast)
 {
-    vhost_log_chunk_t *log = dev->log->log;
+    vhost_log_chunk_t *dev_log = dev->log->log;
 
     uint64_t start = MAX(mfirst, rfirst);
     uint64_t end = MIN(mlast, rlast);
-    vhost_log_chunk_t *from = log + start / VHOST_LOG_CHUNK;
-    vhost_log_chunk_t *to = log + end / VHOST_LOG_CHUNK + 1;
+    vhost_log_chunk_t *from = dev_log + start / VHOST_LOG_CHUNK;
+    vhost_log_chunk_t *to = dev_log + end / VHOST_LOG_CHUNK + 1;
     uint64_t addr = QEMU_ALIGN_DOWN(start, VHOST_LOG_CHUNK);
 
     if (end < start) {
@@ -549,7 +549,7 @@ static void vhost_commit(MemoryListener *listener)
         changed = true;
     } else {
         /* Same size, lets check the contents */
-        for (int i = 0; i < n_old_sections; i++) {
+        for (i = 0; i < n_old_sections; i++) {
             if (!MemoryRegionSection_eq(&old_sections[i],
                                         &dev->mem_sections[i])) {
                 changed = true;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow
  2023-10-04 11:48 [PATCH] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow Thomas Huth
@ 2023-10-04 12:51 ` Michael S. Tsirkin
  2023-10-06  6:26 ` Michael Tokarev
  1 sibling, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2023-10-04 12:51 UTC (permalink / raw)
  To: Thomas Huth; +Cc: qemu-devel, Markus Armbruster, qemu-trivial

On Wed, Oct 04, 2023 at 01:48:09PM +0200, Thomas Huth wrote:
> Rename a variable in vhost_dev_sync_region() and remove a superfluous
> declaration in vhost_commit() to make this code compilable with "-Wshadow".
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>


> ---
>  hw/virtio/vhost.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index e2f6ffb446..9cfac40fde 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -66,12 +66,12 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
>                                    uint64_t mfirst, uint64_t mlast,
>                                    uint64_t rfirst, uint64_t rlast)
>  {
> -    vhost_log_chunk_t *log = dev->log->log;
> +    vhost_log_chunk_t *dev_log = dev->log->log;
>  
>      uint64_t start = MAX(mfirst, rfirst);
>      uint64_t end = MIN(mlast, rlast);
> -    vhost_log_chunk_t *from = log + start / VHOST_LOG_CHUNK;
> -    vhost_log_chunk_t *to = log + end / VHOST_LOG_CHUNK + 1;
> +    vhost_log_chunk_t *from = dev_log + start / VHOST_LOG_CHUNK;
> +    vhost_log_chunk_t *to = dev_log + end / VHOST_LOG_CHUNK + 1;
>      uint64_t addr = QEMU_ALIGN_DOWN(start, VHOST_LOG_CHUNK);
>  
>      if (end < start) {
> @@ -549,7 +549,7 @@ static void vhost_commit(MemoryListener *listener)
>          changed = true;
>      } else {
>          /* Same size, lets check the contents */
> -        for (int i = 0; i < n_old_sections; i++) {
> +        for (i = 0; i < n_old_sections; i++) {
>              if (!MemoryRegionSection_eq(&old_sections[i],
>                                          &dev->mem_sections[i])) {
>                  changed = true;
> -- 
> 2.41.0



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow
  2023-10-04 11:48 [PATCH] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow Thomas Huth
  2023-10-04 12:51 ` Michael S. Tsirkin
@ 2023-10-06  6:26 ` Michael Tokarev
  2023-10-06  8:55   ` Markus Armbruster
  1 sibling, 1 reply; 10+ messages in thread
From: Michael Tokarev @ 2023-10-06  6:26 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Michael S. Tsirkin
  Cc: Markus Armbruster, qemu-trivial

Applied to my trivial-patches tree, thanks!

Marcus, you picked up previous patches of this theme, --
you can continue this tradition if you like :)

/mjt


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow
  2023-10-06  6:26 ` Michael Tokarev
@ 2023-10-06  8:55   ` Markus Armbruster
  2023-10-06 10:45     ` Michael Tokarev
  0 siblings, 1 reply; 10+ messages in thread
From: Markus Armbruster @ 2023-10-06  8:55 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: Thomas Huth, qemu-devel, Michael S. Tsirkin, qemu-trivial

Michael Tokarev <mjt@tls.msk.ru> writes:

> Applied to my trivial-patches tree, thanks!
>
> Marcus, you picked up previous patches of this theme, --
> you can continue this tradition if you like :)

I intend to post a pull request for the -Wshadow patches that have
R-bys.  I'm also tracking the unreviewed ones, and hope they get
reviewed.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow
  2023-10-06  8:55   ` Markus Armbruster
@ 2023-10-06 10:45     ` Michael Tokarev
  2023-10-06 10:51       ` Markus Armbruster
  2023-10-06 11:24       ` Michael S. Tsirkin
  0 siblings, 2 replies; 10+ messages in thread
From: Michael Tokarev @ 2023-10-06 10:45 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Thomas Huth, qemu-devel, Michael S. Tsirkin, qemu-trivial

06.10.2023 11:55, Markus Armbruster пишет:
> Michael Tokarev <mjt@tls.msk.ru> writes:
> 
>> Applied to my trivial-patches tree, thanks!
>>
>> Marcus, you picked up previous patches of this theme, --
>> you can continue this tradition if you like :)
> 
> I intend to post a pull request for the -Wshadow patches that have
> R-bys.  I'm also tracking the unreviewed ones, and hope they get
> reviewed.

Ahh, ok.

I've added my own R-bys for the ones I picked up, and for this one
by Thomas too:

Reviewed-By: Michael Tokarev <mjt@tls.msk.ru>

/mjt



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow
  2023-10-06 10:45     ` Michael Tokarev
@ 2023-10-06 10:51       ` Markus Armbruster
  2023-10-06 11:24       ` Michael S. Tsirkin
  1 sibling, 0 replies; 10+ messages in thread
From: Markus Armbruster @ 2023-10-06 10:51 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: Thomas Huth, qemu-devel, Michael S. Tsirkin, qemu-trivial

Michael Tokarev <mjt@tls.msk.ru> writes:

> 06.10.2023 11:55, Markus Armbruster пишет:
>> Michael Tokarev <mjt@tls.msk.ru> writes:
>> 
>>> Applied to my trivial-patches tree, thanks!
>>>
>>> Marcus, you picked up previous patches of this theme, --
>>> you can continue this tradition if you like :)
>> I intend to post a pull request for the -Wshadow patches that have
>> R-bys.  I'm also tracking the unreviewed ones, and hope they get
>> reviewed.
>
> Ahh, ok.
>
> I've added my own R-bys for the ones I picked up, and for this one
> by Thomas too:
>
> Reviewed-By: Michael Tokarev <mjt@tls.msk.ru>

Got it.

I also got one for

    target/ppc: Rename variables to avoid local variable shadowing in VUPKPX

but that's all.  If you'd like me to add some more, please post them to
the list.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow
  2023-10-06 10:45     ` Michael Tokarev
  2023-10-06 10:51       ` Markus Armbruster
@ 2023-10-06 11:24       ` Michael S. Tsirkin
  2023-10-06 11:38         ` Markus Armbruster
  2023-10-07  9:28         ` Michael Tokarev
  1 sibling, 2 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2023-10-06 11:24 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: Markus Armbruster, Thomas Huth, qemu-devel, qemu-trivial

On Fri, Oct 06, 2023 at 01:45:51PM +0300, Michael Tokarev wrote:
> 06.10.2023 11:55, Markus Armbruster пишет:
> > Michael Tokarev <mjt@tls.msk.ru> writes:
> > 
> > > Applied to my trivial-patches tree, thanks!
> > > 
> > > Marcus, you picked up previous patches of this theme, --
> > > you can continue this tradition if you like :)
> > 
> > I intend to post a pull request for the -Wshadow patches that have
> > R-bys.  I'm also tracking the unreviewed ones, and hope they get
> > reviewed.
> 
> Ahh, ok.
> 
> I've added my own R-bys for the ones I picked up, and for this one
> by Thomas too:
> 
> Reviewed-By: Michael Tokarev <mjt@tls.msk.ru>
> 
> /mjt

it would be better to deal with all of them in one place tbh.

-- 
MST



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow
  2023-10-06 11:24       ` Michael S. Tsirkin
@ 2023-10-06 11:38         ` Markus Armbruster
  2023-10-07  9:28         ` Michael Tokarev
  1 sibling, 0 replies; 10+ messages in thread
From: Markus Armbruster @ 2023-10-06 11:38 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Michael Tokarev, Thomas Huth, qemu-devel, qemu-trivial

"Michael S. Tsirkin" <mst@redhat.com> writes:

> On Fri, Oct 06, 2023 at 01:45:51PM +0300, Michael Tokarev wrote:
>> 06.10.2023 11:55, Markus Armbruster пишет:
>> > Michael Tokarev <mjt@tls.msk.ru> writes:
>> > 
>> > > Applied to my trivial-patches tree, thanks!
>> > > 
>> > > Marcus, you picked up previous patches of this theme, --
>> > > you can continue this tradition if you like :)
>> > 
>> > I intend to post a pull request for the -Wshadow patches that have
>> > R-bys.  I'm also tracking the unreviewed ones, and hope they get
>> > reviewed.
>> 
>> Ahh, ok.
>> 
>> I've added my own R-bys for the ones I picked up, and for this one
>> by Thomas too:
>> 
>> Reviewed-By: Michael Tokarev <mjt@tls.msk.ru>
>> 
>> /mjt
>
> it would be better to deal with all of them in one place tbh.

I just sent a pull request.  Thanks for all the reviews!



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow
  2023-10-06 11:24       ` Michael S. Tsirkin
  2023-10-06 11:38         ` Markus Armbruster
@ 2023-10-07  9:28         ` Michael Tokarev
  2023-10-09  6:02           ` Markus Armbruster
  1 sibling, 1 reply; 10+ messages in thread
From: Michael Tokarev @ 2023-10-07  9:28 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Markus Armbruster, Thomas Huth, qemu-devel, qemu-trivial

06.10.2023 14:24, Michael S. Tsirkin:
> On Fri, Oct 06, 2023 at 01:45:51PM +0300, Michael Tokarev wrote:
>> 06.10.2023 11:55, Markus Armbruster пишет:
>>> Michael Tokarev <mjt@tls.msk.ru> writes:
>>>
>>>> Applied to my trivial-patches tree, thanks!
>>>>
>>>> Marcus, you picked up previous patches of this theme, --
>>>> you can continue this tradition if you like :)
>>>
>>> I intend to post a pull request for the -Wshadow patches that have
>>> R-bys.  I'm also tracking the unreviewed ones, and hope they get
>>> reviewed.
>>
>> Ahh, ok.
>>
>> I've added my own R-bys for the ones I picked up, and for this one
>> by Thomas too:
>>
>> Reviewed-By: Michael Tokarev <mjt@tls.msk.ru>
> 
> it would be better to deal with all of them in one place tbh.

This is exactly why I asked Marcus about this in the first place,
being confused a bit with the stuff being especially sent to
qemu-trivial@ :)

/mjt



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow
  2023-10-07  9:28         ` Michael Tokarev
@ 2023-10-09  6:02           ` Markus Armbruster
  0 siblings, 0 replies; 10+ messages in thread
From: Markus Armbruster @ 2023-10-09  6:02 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: Michael S. Tsirkin, Thomas Huth, qemu-devel, qemu-trivial

Michael Tokarev <mjt@tls.msk.ru> writes:

> 06.10.2023 14:24, Michael S. Tsirkin:
>> On Fri, Oct 06, 2023 at 01:45:51PM +0300, Michael Tokarev wrote:
>>> 06.10.2023 11:55, Markus Armbruster пишет:
>>>> Michael Tokarev <mjt@tls.msk.ru> writes:
>>>>
>>>>> Applied to my trivial-patches tree, thanks!
>>>>>
>>>>> Marcus, you picked up previous patches of this theme, --
>>>>> you can continue this tradition if you like :)
>>>>
>>>> I intend to post a pull request for the -Wshadow patches that have
>>>> R-bys.  I'm also tracking the unreviewed ones, and hope they get
>>>> reviewed.
>>>
>>> Ahh, ok.
>>>
>>> I've added my own R-bys for the ones I picked up, and for this one
>>> by Thomas too:
>>>
>>> Reviewed-By: Michael Tokarev <mjt@tls.msk.ru>
>>
>> it would be better to deal with all of them in one place tbh.
>
> This is exactly why I asked Marcus about this in the first place,
> being confused a bit with the stuff being especially sent to
> qemu-trivial@ :)

This patch is in my latest PR[*], along with all the other shadow
patches that were ready at the time.  A few more are coming down the
pipe, which I can take through my tree, too.


[*] [PULL 00/32] -Wshadow=local patches patches for 2023-10-06
Message-ID: <20231006113657.3803180-1-armbru@redhat.com>



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-10-09  6:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-04 11:48 [PATCH] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow Thomas Huth
2023-10-04 12:51 ` Michael S. Tsirkin
2023-10-06  6:26 ` Michael Tokarev
2023-10-06  8:55   ` Markus Armbruster
2023-10-06 10:45     ` Michael Tokarev
2023-10-06 10:51       ` Markus Armbruster
2023-10-06 11:24       ` Michael S. Tsirkin
2023-10-06 11:38         ` Markus Armbruster
2023-10-07  9:28         ` Michael Tokarev
2023-10-09  6:02           ` Markus Armbruster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).