Skip to contentSkip to conversation

s390/nmi: Simplify return statement in nmi_registers_valid()

PATCH In review Thorsten Blum 3 participants 4 messages Sep 8, 2025 – Sep 9, 2025 s390

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390/nmi: Simplify return statement in nmi_registers_valid()

Don't negate the 'mci.*' operands and use the logical AND operator to simplify the return statement.

No functional changes intended.

---
 arch/s390/kernel/nmi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/s390/kernel/nmi.c +1 -3
index 11f33243a23f..cbefd6bde104 100644
@@ -321,9 +321,7 @@ static bool notrace nmi_registers_valid(union mci mci)
 	cr2.reg = get_lowcore()->cregs_save_area[2];
 	if (cr2.gse && !mci.gs && !test_cpu_flag(CIF_MCCK_GUEST))
 		return false;
-	if (!mci.ms || !mci.pm || !mci.ia)
-		return false;
-	return true;
+	return mci.ms && mci.pm && mci.ia;
 }
 NOKPROBE_SYMBOL(nmi_registers_valid);
 
Signature · 1 line
2.51.0
#1 lore raw

On Mon, Sep 08, 2025 at 05:32:20PM +0200, Thorsten Blum wrote:
...

arch/s390/kernel/nmi.c static bool notrace nmi_registers_valid(union mci mci) · line 326

Quoted 10 lines
arch/s390/kernel/nmi.c +1 -3
@@ -321,9 +321,7 @@ static bool notrace nmi_registers_valid(union mci mci)
 	cr2.reg = get_lowcore()->cregs_save_area[2];
 	if (cr2.gse && !mci.gs && !test_cpu_flag(CIF_MCCK_GUEST))
 		return false;
-	if (!mci.ms || !mci.pm || !mci.ia)
-		return false;
-	return true;
+	return mci.ms && mci.pm && mci.ia;
 }
 NOKPROBE_SYMBOL(nmi_registers_valid);

This change does not make the whole function readability better.

Thanks!

maintainer
#2 lore raw
Quoted 14 lines · Alexander Gordeev

On Mon, Sep 08, 2025 at 05:32:20PM +0200, Thorsten Blum wrote:
...

arch/s390/kernel/nmi.c static bool notrace nmi_registers_valid(union mci mci) · line 326

Quoted 10 lines
arch/s390/kernel/nmi.c +1 -3
@@ -321,9 +321,7 @@ static bool notrace nmi_registers_valid(union mci mci)
 	cr2.reg = get_lowcore()->cregs_save_area[2];
 	if (cr2.gse && !mci.gs && !test_cpu_flag(CIF_MCCK_GUEST))
 		return false;
-	if (!mci.ms || !mci.pm || !mci.ia)
-		return false;
-	return true;
+	return mci.ms && mci.pm && mci.ia;
 }
 NOKPROBE_SYMBOL(nmi_registers_valid);

This change does not make the whole function readability better.

It actually would decrease readability since every if-statement tells you one condition when registers are not valid. Negating the last one makes this harder to understand.

But in general please do not send patches like this, which do not come with a significant improvement.

#3 lore raw
Quoted 7 lines · Heiko Carstens
Quoted 2 lines · Alexander Gordeev

This change does not make the whole function readability better.

It actually would decrease readability since every if-statement tells you one condition when registers are not valid. Negating the last one makes this harder to understand.

Ah my bad, that makes sense. I didn't take the whole function into account.

Thanks,
Thorsten