Skip to contentSkip to conversation

hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow

PATCH Applied Thomas Huth 4 participants 10 messages Oct 4, 2023 – Oct 9, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow

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

---
 hw/virtio/vhost.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/virtio/vhost.c +4 -4
index e2f6ffb446..9cfac40fde 100644
@@ -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;
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Thomas Huth

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

Quoted 35 lines
---
 hw/virtio/vhost.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/virtio/vhost.c +4 -4
index e2f6ffb446..9cfac40fde 100644
@@ -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;
Signature · 1 line
2.41.0
#3 lore raw
Quoted 4 lines · Michael Tokarev

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.

Reviewed-by
#4 lore raw

06.10.2023 11:55, Markus Armbruster пишет:

Quoted 10 lines
Quoted 4 lines · Michael Tokarev

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:

/mjt

#5 lore raw
Quoted 11 lines · Michael Tokarev

06.10.2023 11:55, Markus Armbruster пишет:

Quoted 9 lines
Quoted 4 lines · Michael Tokarev

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.

Quoted 6 lines

Ahh, ok.

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

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.

#6 lore raw
In reply to Michael Tokarev
Quoted 12 lines · Michael Tokarev

06.10.2023 11:55, Markus Armbruster пишет:

Quoted 10 lines
Quoted 4 lines · Michael Tokarev

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.

Quoted 8 lines

Ahh, ok.

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

/mjt

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

Signature · 1 line
MST
#7 lore raw
Quoted 15 lines · Michael S. Tsirkin
Quoted 14 lines · Michael Tokarev

06.10.2023 11:55, Markus Armbruster пишет:

Quoted 10 lines
Quoted 4 lines · Michael Tokarev

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.

Quoted 8 lines
Quoted 6 lines

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

/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!

#8 lore raw
In reply to Michael S. Tsirkin

06.10.2023 14:24, Michael S. Tsirkin:

Quoted 13 lines · Michael Tokarev
Quoted 12 lines

06.10.2023 11:55, Markus Armbruster пишет:

Quoted 10 lines
Quoted 4 lines · Michael Tokarev

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.

Quoted 8 lines
Quoted 6 lines

Ahh, ok.

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

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

#9 lore raw
Quoted 19 lines · Michael Tokarev

06.10.2023 14:24, Michael S. Tsirkin:

Quoted 18 lines · Michael Tokarev
Quoted 17 lines

06.10.2023 11:55, Markus Armbruster пишет:

Quoted 10 lines
Quoted 4 lines · Michael Tokarev

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:

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

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: <[email protected]>