Skip to contentSkip to conversation

raw/ioat: fix parameter shadow warning

PATCH Superseded Kevin Laatz 5 participants 11 messages May 7, 2021 – May 12, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 raw/ioat: fix parameter shadow warning

In the function __idxd_completed_ops() we have a parameter shadow warning due to a local variable having the same name as one of the function parameters. This is fixed by simply renaming the local variable.

Fixes 245efe544d8e ("raw/ioat: report status of completed jobs")
---
 drivers/raw/ioat/rte_idxd_rawdev_fns.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/raw/ioat/rte_idxd_rawdev_fns.h +3 -3
index 862e0eb41d..dbd8dfc507 100644
@@ -301,11 +301,11 @@ __idxd_completed_ops(int dev_id, uint8_t max_ops, uint32_t *status, uint8_t *num
 		uint16_t idx_to_chk = idxd->batch_idx_ring[idxd->batch_idx_read];
 		volatile struct rte_idxd_completion *comp_to_chk =
 				(struct rte_idxd_completion *)&idxd->desc_ring[idx_to_chk];
-		uint8_t status = comp_to_chk->status;
-		if (status == 0)
+		uint8_t batch_status = comp_to_chk->status;
+		if (batch_status == 0)
 			break;
 		comp_to_chk->status = 0;
-		if (unlikely(status > 1)) {
+		if (unlikely(batch_status > 1)) {
 			/* error occurred somewhere in batch, start where last checked */
 			uint16_t desc_count = comp_to_chk->completed_size;
 			uint16_t batch_start = idxd->hdls_avail;
Signature · 1 line
2.30.2
#2 lore raw
In reply to Kevin Laatz
Quoted 9 lines · Kevin Laatz

In the function __idxd_completed_ops() we have a parameter shadow warning due to a local variable having the same name as one of the function parameters. This is fixed by simply renaming the local variable.

Fixes 245efe544d8e ("raw/ioat: report status of completed jobs")

---

Please provide details in the commit log as to how/when this was seen. I believe this issue was seen only with OVS because it passes the -Wshadow flag when building - something DPDK probably should do, but doesn't. Is that correct?

#3 lore raw
Quoted 9 lines · Kevin Laatz
Quoted 1 line

In the function __idxd_completed_ops() we have a parameter shadow

warning

Quoted 5 lines

due to a local variable having the same name as one of the function parameters. This is fixed by simply renaming the local variable.

Fixes 245efe544d8e ("raw/ioat: report status of completed jobs")
Quoted 7 lines
Quoted 3 lines

---

Please provide details in the commit log as to how/when this was seen. I believe this issue was seen only with OVS because it passes the -Wshadow flag when building - something DPDK probably should do, but doesn't. Is that correct?

Correct, the OVS build has -Wshadow by default. When -Wshadow is passed to the DPDK build, this warning is also visible.

Will send a V2 to include details in commit log.

#4 lore raw

PATCH v2 1/1 raw/ioat: fix parameter shadow warning

In reply to Kevin Laatz

In the function __idxd_completed_ops() we have a parameter shadow warning due to a local variable having the same name as one of the function parameters. This issue is fixed by simply renaming the local variable.

This warning was discovered during an OVS build with DPDK 21.05-rc2. The OVS build passes the -Wshadow flag by default, allowing the warning to be seen.

Fixes 245efe544d8e ("raw/ioat: report status of completed jobs")

---
v2: add details of warning discovery

---
 drivers/raw/ioat/rte_idxd_rawdev_fns.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/raw/ioat/rte_idxd_rawdev_fns.h +3 -3
index 862e0eb41d..dbd8dfc507 100644
@@ -301,11 +301,11 @@ __idxd_completed_ops(int dev_id, uint8_t max_ops, uint32_t *status, uint8_t *num
 		uint16_t idx_to_chk = idxd->batch_idx_ring[idxd->batch_idx_read];
 		volatile struct rte_idxd_completion *comp_to_chk =
 				(struct rte_idxd_completion *)&idxd->desc_ring[idx_to_chk];
-		uint8_t status = comp_to_chk->status;
-		if (status == 0)
+		uint8_t batch_status = comp_to_chk->status;
+		if (batch_status == 0)
 			break;
 		comp_to_chk->status = 0;
-		if (unlikely(status > 1)) {
+		if (unlikely(batch_status > 1)) {
 			/* error occurred somewhere in batch, start where last checked */
 			uint16_t desc_count = comp_to_chk->completed_size;
 			uint16_t batch_start = idxd->hdls_avail;
Signature · 1 line
2.30.2
Acked-by on v2 1/1
#5 lore raw
Quoted 8 lines · Kevin Laatz

In the function __idxd_completed_ops() we have a parameter shadow warning due to a local variable having the same name as one of the function parameters. This issue is fixed by simply renaming the local variable.

This warning was discovered during an OVS build with DPDK 21.05-rc2. The OVS build passes the -Wshadow flag by default, allowing the warning to be seen.

Quoted 7 lines
Fixes 245efe544d8e ("raw/ioat: report status of completed jobs")

---

#6 lore raw
In reply to Kevin Laatz
Quoted 8 lines · Kevin Laatz

In the function __idxd_completed_ops() we have a parameter shadow warning due to a local variable having the same name as one of the function parameters. This issue is fixed by simply renaming the local variable.

This warning was discovered during an OVS build with DPDK 21.05-rc2. The OVS build passes the -Wshadow flag by default, allowing the warning to be seen.

A bit confusing.
-Wshadow only affects OVS code and there is no code calling this in the OVS master branch.

I did not see this issue while updating my dpdk-latest OVS branch and running builds in GHA.
So I guess Sunil caught it with his patch:
https://patchwork.ozlabs.org/project/openvswitch/patch/[email protected]/

Signature · 1 line
David Marchand
#7 lore raw
Quoted 10 lines · David Marchand
Quoted 8 lines · Kevin Laatz

In the function __idxd_completed_ops() we have a parameter shadow warning due to a local variable having the same name as one of the function parameters. This issue is fixed by simply renaming the local variable.

This warning was discovered during an OVS build with DPDK 21.05-rc2. The OVS build passes the -Wshadow flag by default, allowing the warning to be seen.

Quoted 9 lines

A bit confusing.
-Wshadow only affects OVS code and there is no code calling this in the OVS master branch.

I did not see this issue while updating my dpdk-latest OVS branch and running builds in GHA.
So I guess Sunil caught it with his patch:
https://patchwork.ozlabs.org/project/openvswitch/patch/[email protected]/

Yes, it was caught by Sunil in the course of his work.

Ideally, I think -Wshadow would be a good flag to add to our DPDK builds, but it causes quite a number of errors right now to do so. Hopefully in a future release.

/Bruce

#8 lore raw

10/05/2021 16:48, Bruce Richardson:

Quoted 15 lines · David Marchand
Quoted 14 lines · Kevin Laatz
Quoted 8 lines

In the function __idxd_completed_ops() we have a parameter shadow warning due to a local variable having the same name as one of the function parameters. This issue is fixed by simply renaming the local variable.

This warning was discovered during an OVS build with DPDK 21.05-rc2. The OVS build passes the -Wshadow flag by default, allowing the warning to be seen.

A bit confusing.
-Wshadow only affects OVS code and there is no code calling this in the OVS master branch.

Quoted 6 lines
Quoted 5 lines

I did not see this issue while updating my dpdk-latest OVS branch and running builds in GHA.
So I guess Sunil caught it with his patch:
https://patchwork.ozlabs.org/project/openvswitch/patch/[email protected]/

Yes, it was caught by Sunil in the course of his work.

So the commit message should be fixed please.

#9 lore raw

PATCH v3 1/1 raw/ioat: fix parameter shadow warning

In reply to Kevin Laatz

In the function __idxd_completed_ops() we have a parameter shadow warning due to a local variable having the same name as one of the function parameters. This issue is fixed by simply renaming the local variable.

This warning was caught when additions were made to the OVS codebase, which include adding calls the IOAT APIs. The OVS build passes the -Wshadow flag by default, allowing the warning to be seen when building OVS with DPDK 21.05-rc2.

Fixes 245efe544d8e ("raw/ioat: report status of completed jobs")

---
v2: add details of warning discovery
v3: commit log update

---
 drivers/raw/ioat/rte_idxd_rawdev_fns.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/raw/ioat/rte_idxd_rawdev_fns.h +3 -3
index 862e0eb41d..dbd8dfc507 100644
@@ -301,11 +301,11 @@ __idxd_completed_ops(int dev_id, uint8_t max_ops, uint32_t *status, uint8_t *num
 		uint16_t idx_to_chk = idxd->batch_idx_ring[idxd->batch_idx_read];
 		volatile struct rte_idxd_completion *comp_to_chk =
 				(struct rte_idxd_completion *)&idxd->desc_ring[idx_to_chk];
-		uint8_t status = comp_to_chk->status;
-		if (status == 0)
+		uint8_t batch_status = comp_to_chk->status;
+		if (batch_status == 0)
 			break;
 		comp_to_chk->status = 0;
-		if (unlikely(status > 1)) {
+		if (unlikely(batch_status > 1)) {
 			/* error occurred somewhere in batch, start where last checked */
 			uint16_t desc_count = comp_to_chk->completed_size;
 			uint16_t batch_start = idxd->hdls_avail;
Signature · 1 line
2.30.2
#10 lore raw

12/05/2021 12:47, Kevin Laatz:

Quoted 9 lines

In the function __idxd_completed_ops() we have a parameter shadow warning due to a local variable having the same name as one of the function parameters. This issue is fixed by simply renaming the local variable.

This warning was caught when additions were made to the OVS codebase, which include adding calls the IOAT APIs. The OVS build passes the -Wshadow flag by default, allowing the warning to be seen when building OVS with DPDK 21.05-rc2.

Quoted 6 lines
Fixes 245efe544d8e ("raw/ioat: report status of completed jobs")

Applied, thanks.