Skip to contentSkip to conversation

linux-4.11-rc6/arch/sparc/kernel/setup_32.c:151]: (style) Redundant condition

DISCUSSION David Miller 1 participant 1 message May 3, 2017 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

From: David Binderman <[email protected]>
Date: Mon, 10 Apr 2017 08:20:09 +0000

Quoted 12 lines

Hello there,

linux-4.11-rc6/arch/sparc/kernel/setup_32.c:151]: (style) Redundant condition: If 'EXPR = ' '', the comparison 'EXPR' is always true.

Source code is

        while (*commands && *commands = ' ')
Quoted 8 lines

Suggest new code

        while (*commands = ' ')

Also, there seems to be a duplicate in a similar file:

linux-4.11-rc6/arch/sparc/kernel/setup_64.c:136]: (style) Redundant condition: If 'EXPR = ' '', the comparison 'EXPR' is always true.

Yep, both are correct transformations, thanks.

==========
sparc: Remove redundant tests in boot_flags_init().

The test:

	*commands && *commands = ' '

is equivalent to:

	*commands = ' '
---
 arch/sparc/kernel/setup_32.c | 2 +-
 arch/sparc/kernel/setup_64.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/sparc/kernel/setup_32.c +1 -1
index 6f06058..6722308 100644
@@ -148,7 +148,7 @@ static void __init boot_flags_init(char *commands)
 {
 	while (*commands) {
 		/* Move to the start of the next "argument". */
-		while (*commands && *commands = ' ')
+		while (*commands = ' ')
 			commands++;
 
 		/* Process any command switches, otherwise skip it. */
arch/sparc/kernel/setup_64.c +1 -1
index 6b7331d..422b178 100644
@@ -133,7 +133,7 @@ static void __init boot_flags_init(char *commands)
 {
 	while (*commands) {
 		/* Move to the start of the next "argument". */
-		while (*commands && *commands = ' ')
+		while (*commands = ' ')
 			commands++;
 
 		/* Process any command switches, otherwise skip it. */
Signature · 1 line
2.1.2.532.g19b5d50