Skip to contentSkip to conversation

arch/powerpc: Remove unnecessary endian conversion code in XICS

PATCH In review Gautam Menghani 4 participants 8 messages Jun 30, 2023 – Jul 31, 2023 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arch/powerpc: Remove unnecessary endian conversion code in XICS

Remove an unnecessary piece of code that does an endianness conversion but does not use the result. The following warning was reported by Clang's static analyzer:

arch/powerpc/sysdev/xics/ics-opal.c:114:2: warning: Value stored to 'server' is never read [deadcode.DeadStores]

        server = be16_to_cpu(oserver);

As the result of endianness conversion is never used, delete the line and fix the warning.

---
 arch/powerpc/sysdev/xics/ics-opal.c | 1 -
 1 file changed, 1 deletion(-)
arch/powerpc/sysdev/xics/ics-opal.c +0 -1
index 6cfbb4fac7fb..5fe73dabab79 100644
@@ -111,7 +111,6 @@ static int ics_opal_set_affinity(struct irq_data *d,
 		       __func__, d->irq, hw_irq, rc);
 		return -1;
 	}
-	server = be16_to_cpu(oserver);
 
 	wanted_server = xics_get_irq_server(d->irq, cpumask, 1);
 	if (wanted_server < 0) {
Signature · 1 line
2.39.3
#1 lore raw
Quoted 21 lines · Gautam Menghani

Remove an unnecessary piece of code that does an endianness conversion but does not use the result. The following warning was reported by Clang's static analyzer:

arch/powerpc/sysdev/xics/ics-opal.c:114:2: warning: Value stored to 'server' is never read [deadcode.DeadStores]

        server = be16_to_cpu(oserver);

As the result of endianness conversion is never used, delete the line and fix the warning.

---
 arch/powerpc/sysdev/xics/ics-opal.c | 1 -
 1 file changed, 1 deletion(-)
arch/powerpc/sysdev/xics/ics-opal.c +0 -0
index 6cfbb4fac7fb..5fe73dabab79 100644

arch/powerpc/sysdev/xics/ics-opal.c static int ics_opal_set_affinity(struct irq_data *d, · line 116

Quoted 7 lines
arch/powerpc/sysdev/xics/ics-opal.c +0 -1
@@ -111,7 +111,6 @@ static int ics_opal_set_affinity(struct irq_data *d,
 		       __func__, d->irq, hw_irq, rc);
 		return -1;
 	}
-	server = be16_to_cpu(oserver);
 
 	wanted_server = xics_get_irq_server(d->irq, cpumask, 1);
 	if (wanted_server < 0) {

My first question with a patch like this is always going to be "how did the code end up like this?"

Has the code changed and this assignment became unused? If so the commit that did that should be identified.

If the code has always been like this that's also useful to know. Or something else happened for it to end up this way :)

The second question will be "is there actually a bug here?". ie. should server actually be used, and the bug is not that it's a dead assignment but rather that server is not where it should be.

cheers

Reviewed-by on v1 1/1
#2 lore raw
In reply to Gautam Menghani
Quoted 4 lines · Gautam Menghani

Remove an unnecessary piece of code that does an endianness conversion but does not use the result. The following warning was reported by Clang's static analyzer:

Quoted 8 lines

arch/powerpc/sysdev/xics/ics-opal.c:114:2: warning: Value stored to 'server' is never read [deadcode.DeadStores]

         server = be16_to_cpu(oserver);

As the result of endianness conversion is never used, delete the line and fix the warning.

'server' was used as a parameter to opal_get_xive() in commit 5c7c1e9444d8 ("powerpc/powernv: Add OPAL ICS backend") when it was introduced. 'server' was also used in an error message for the call to opal_get_xive().

'server' was always later set by a call to ics_opal_mangle_server() before being used.

Commit bf8e0f891a32 ("powerpc/powernv: Fix endian issues in OPAL ICS backend") used a new variable 'oserver' as the parameter to opal_get_xive() instead of 'server' for endian correctness. It also removed 'server' from the error message for the call to opal_get_xive().

It was commit bf8e0f891a32 that added the unnecessary conversion and never used the result.

Quoted 17 lines
---
  arch/powerpc/sysdev/xics/ics-opal.c | 1 -
  1 file changed, 1 deletion(-)
arch/powerpc/sysdev/xics/ics-opal.c +0 -1
index 6cfbb4fac7fb..5fe73dabab79 100644
@@ -111,7 +111,6 @@ static int ics_opal_set_affinity(struct irq_data *d,
  		       __func__, d->irq, hw_irq, rc);
  		return -1;
  	}
-	server = be16_to_cpu(oserver);
 
  	wanted_server = xics_get_irq_server(d->irq, cpumask, 1);
  	if (wanted_server < 0) {
#3 lore raw
Quoted 28 lines · Jordan Niethe
Quoted 4 lines · Gautam Menghani

Remove an unnecessary piece of code that does an endianness conversion but does not use the result. The following warning was reported by Clang's static analyzer:

Quoted 8 lines

arch/powerpc/sysdev/xics/ics-opal.c:114:2: warning: Value stored to 'server' is never read [deadcode.DeadStores]

         server = be16_to_cpu(oserver);

As the result of endianness conversion is never used, delete the line and fix the warning.

'server' was used as a parameter to opal_get_xive() in commit 5c7c1e9444d8 ("powerpc/powernv: Add OPAL ICS backend") when it was introduced. 'server' was also used in an error message for the call to opal_get_xive().

'server' was always later set by a call to ics_opal_mangle_server() before being used.

Commit bf8e0f891a32 ("powerpc/powernv: Fix endian issues in OPAL ICS backend") used a new variable 'oserver' as the parameter to opal_get_xive() instead of 'server' for endian correctness. It also removed 'server' from the error message for the call to opal_get_xive().

Quoted 4 lines

It was commit bf8e0f891a32 that added the unnecessary conversion and never used the result.

Yes, thanks for the info Jordan. Just to add to this, ics_opal_mangle_server() needs input in LE and the 'wanted_server' is already LE as xics_get_irq_server() is returning result in LE. So the line

`server = be16_to_cpu(oserver);'

is indeed not required.

Thanks,
Gautam

Quoted 18 lines
Quoted 18 lines

---
  arch/powerpc/sysdev/xics/ics-opal.c | 1 -
  1 file changed, 1 deletion(-)
arch/powerpc/sysdev/xics/ics-opal.c +0 -1
index 6cfbb4fac7fb..5fe73dabab79 100644
@@ -111,7 +111,6 @@ static int ics_opal_set_affinity(struct irq_data *d,
  		       __func__, d->irq, hw_irq, rc);
  		return -1;
  	}
-	server = be16_to_cpu(oserver);
  	wanted_server = xics_get_irq_server(d->irq, cpumask, 1);
  	if (wanted_server < 0) {
 
#4 lore raw
In reply to Jordan Niethe
Quoted 28 lines · Jordan Niethe
Quoted 4 lines · Gautam Menghani

Remove an unnecessary piece of code that does an endianness conversion but does not use the result. The following warning was reported by Clang's static analyzer:

Quoted 8 lines

arch/powerpc/sysdev/xics/ics-opal.c:114:2: warning: Value stored to 'server' is never read [deadcode.DeadStores]

         server = be16_to_cpu(oserver);

As the result of endianness conversion is never used, delete the line and fix the warning.

'server' was used as a parameter to opal_get_xive() in commit 5c7c1e9444d8 ("powerpc/powernv: Add OPAL ICS backend") when it was introduced. 'server' was also used in an error message for the call to opal_get_xive().

'server' was always later set by a call to ics_opal_mangle_server() before being used.

Commit bf8e0f891a32 ("powerpc/powernv: Fix endian issues in OPAL ICS backend") used a new variable 'oserver' as the parameter to opal_get_xive() instead of 'server' for endian correctness. It also removed 'server' from the error message for the call to opal_get_xive().

Quoted 5 lines

It was commit bf8e0f891a32 that added the unnecessary conversion and never used the result.

Hello Michael,

Do you have any more questions on this patch or is it good to go?

Thanks,
Gautam

#5 lore raw
In reply to Jordan Niethe
Quoted 28 lines · Jordan Niethe
Quoted 4 lines · Gautam Menghani

Remove an unnecessary piece of code that does an endianness conversion but does not use the result. The following warning was reported by Clang's static analyzer:

Quoted 8 lines

arch/powerpc/sysdev/xics/ics-opal.c:114:2: warning: Value stored to 'server' is never read [deadcode.DeadStores]

         server = be16_to_cpu(oserver);

As the result of endianness conversion is never used, delete the line and fix the warning.

'server' was used as a parameter to opal_get_xive() in commit 5c7c1e9444d8 ("powerpc/powernv: Add OPAL ICS backend") when it was introduced. 'server' was also used in an error message for the call to opal_get_xive().

'server' was always later set by a call to ics_opal_mangle_server() before being used.

Commit bf8e0f891a32 ("powerpc/powernv: Fix endian issues in OPAL ICS backend") used a new variable 'oserver' as the parameter to opal_get_xive() instead of 'server' for endian correctness. It also removed 'server' from the error message for the call to opal_get_xive().

Quoted 5 lines

It was commit bf8e0f891a32 that added the unnecessary conversion and never used the result.

Hello Michael,

Do you have any more questions on this patch or is it good to go?

Thanks,
Gautam

#6 lore raw
Quoted 30 lines · Gautam Menghani
Quoted 29 lines · Jordan Niethe
Quoted 4 lines · Gautam Menghani

Remove an unnecessary piece of code that does an endianness conversion but does not use the result. The following warning was reported by Clang's static analyzer:

Quoted 8 lines

arch/powerpc/sysdev/xics/ics-opal.c:114:2: warning: Value stored to 'server' is never read [deadcode.DeadStores]

         server = be16_to_cpu(oserver);

As the result of endianness conversion is never used, delete the line and fix the warning.

'server' was used as a parameter to opal_get_xive() in commit 5c7c1e9444d8 ("powerpc/powernv: Add OPAL ICS backend") when it was introduced. 'server' was also used in an error message for the call to opal_get_xive().

'server' was always later set by a call to ics_opal_mangle_server() before being used.

Commit bf8e0f891a32 ("powerpc/powernv: Fix endian issues in OPAL ICS backend") used a new variable 'oserver' as the parameter to opal_get_xive() instead of 'server' for endian correctness. It also removed 'server' from the error message for the call to opal_get_xive().

It was commit bf8e0f891a32 that added the unnecessary conversion and never used the result.

Quoted 6 lines
Quoted 2 lines

Hello Michael,

Do you have any more questions on this patch or is it good to go?

I was expecting you'd send a v2 with the changelog updated to include all the extra detail Jordan added. I think it should also be tagged as

Fixes bf8e0f891a32.

cheers

#7 lore raw
Quoted 36 lines · Michael Ellerman
Quoted 35 lines · Gautam Menghani
Quoted 26 lines · Jordan Niethe
Quoted 4 lines · Gautam Menghani

Remove an unnecessary piece of code that does an endianness conversion but does not use the result. The following warning was reported by Clang's static analyzer:

Quoted 8 lines

arch/powerpc/sysdev/xics/ics-opal.c:114:2: warning: Value stored to 'server' is never read [deadcode.DeadStores]

         server = be16_to_cpu(oserver);

As the result of endianness conversion is never used, delete the line and fix the warning.

'server' was used as a parameter to opal_get_xive() in commit 5c7c1e9444d8 ("powerpc/powernv: Add OPAL ICS backend") when it was introduced. 'server' was also used in an error message for the call to opal_get_xive().

'server' was always later set by a call to ics_opal_mangle_server() before being used.

Commit bf8e0f891a32 ("powerpc/powernv: Fix endian issues in OPAL ICS backend") used a new variable 'oserver' as the parameter to opal_get_xive() instead of 'server' for endian correctness. It also removed 'server' from the error message for the call to opal_get_xive().

Quoted 5 lines

It was commit bf8e0f891a32 that added the unnecessary conversion and never used the result.

Hello Michael,

Quoted 7 lines
Quoted 1 line

Do you have any more questions on this patch or is it good to go?

I was expecting you'd send a v2 with the changelog updated to include all the extra detail Jordan added. I think it should also be tagged as

Fixes bf8e0f891a32.

cheers

Thanks for the response. I've sent a v2 here - lore.kernel.org/linuxppc-dev/[email protected]/T/#u

Thanks,
Gautam