drivers/fbtft: Remove unnecessary braces from if/else
Subsystems (2)
PATCH 2/3 drivers/fbtft: Remove unnecessary braces from if/else
The Linux kernel coding style states that braces should only be used when necessary.
This fixes the checkpatch warning
WARNING: line over 80 characters
+ } else if (display->regwidth == 8 && display->buswidth == 9 && par->spi) {
introduced by patch #1.
--- drivers/staging/fbtft/fbtft-core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/fbtft/fbtft-core.c +5 -6
@@ -1367,19 +1367,18 @@ int fbtft_probe_common(struct fbtft_display *display, }/* write register functions */ -if (display->regwidth ==8 && display->buswidth ==8 ) { +if (display->regwidth ==8 && display->buswidth ==8 ) par->fbtftops.write_register = fbtft_write_reg8_bus8; - }else if (display->regwidth ==8 && display->buswidth ==9 && par->spi) { +else if (display->regwidth ==8 && display->buswidth ==9 && par->spi) par->fbtftops.write_register = fbtft_write_reg8_bus9; - }else if (display->regwidth ==16 && display->buswidth ==8 ) { +else if (display->regwidth ==16 && display->buswidth ==8 ) par->fbtftops.write_register = fbtft_write_reg16_bus8; - }else if (display->regwidth ==16 && display->buswidth ==16 ) { +else if (display->regwidth ==16 && display->buswidth ==16 ) par->fbtftops.write_register = fbtft_write_reg16_bus16; - }else { +else dev_warn (dev,"no default functions for regwidth=%d and buswidth=%d\n" , display->regwidth, display->buswidth); - }/* write_vmem() functions */ if (display->buswidth ==8 )
Signature · 1 line
2.7.4
Quoted 10 lines · Luis Gerhorst
The Linux kernel coding style states that braces should only be used when necessary.
This fixes the checkpatch warning
WARNING: line over 80 characters
(quoted diff) +1
-0+ } else if (display->regwidth == 8 && display->buswidth == 9 && par->spi) {introduced by patch #1.
Don't introduce warnings and then fix them in later patches.
Anyway there is another unwritten rule that multi-line indents get curly braces. Probably it should be:
} else if (display->regwidth == 8 && display->buswidth == 9 &&
par->spi) {regards,
dan carpenter
Quoted 9 lines · Dan Carpenter
Quoted 8 lines · Luis Gerhorst
The Linux kernel coding style states that braces should only be used when necessary.
This fixes the checkpatch warning
WARNING: line over 80 characters
(quoted diff) +1
-0+ } else if (display->regwidth == 8 && display->buswidth == 9 && par->spi) {
Quoted 7 lines
Quoted 2 lines
introduced by patch #1.
Don't introduce warnings and then fix them in later patches.
Anyway there is another unwritten rule that multi-line indents get curly braces. Probably it should be:
Nope. That'd be your own preferred style.
If you want it to be followed by others, please try and get it added to CodingStyle and use examples to show why it's better than allowing maintainer preference.
Quoted 2 lines
} else if (display->regwidth == 8 && display->buswidth == 9 &&
par->spi) {My own preferred style here would be to align the display->regwidth and display->buswidth so I can differentiate the similarity in naming a bit more easily.
} else if (display->regwidth == 8 &&
display->buswidth == 9 && par->spi) {I'm not sure at all there is a single best style for this and it can easily become situation dependent.
And so I suggest not adding anything about this style nit to CodingStyle.
Quoted 15 lines · Joe Perches
Quoted 14 lines · Dan Carpenter
Quoted 10 lines · Luis Gerhorst
The Linux kernel coding style states that braces should only be used when necessary.
This fixes the checkpatch warning
WARNING: line over 80 characters
(quoted diff) +1
-0+ } else if (display->regwidth == 8 && display->buswidth == 9 && par->spi) {introduced by patch #1.
Don't introduce warnings and then fix them in later patches.
Quoted 5 lines
Quoted 2 lines
Anyway there is another unwritten rule that multi-line indents get curly braces. Probably it should be:
Nope. That'd be your own preferred style.
I copied it from Greg so it's the subsystem style.
Quoted 5 lines
If you want it to be followed by others, please try and get it added to CodingStyle and use examples to show why it's better than allowing maintainer preference.
I'm not going to NACK patches which don't follow that rule, so it's not something which is helpful to put in checkpatch.pl. The reason I'm complaining about this patch is that it fixes a patch the author introduces earlier in the patchset.
Quoted 7 lines
Quoted 2 lines
} else if (display->regwidth == 8 && display->buswidth == 9 && par->spi) {My own preferred style here would be to align the
display->regwidthanddisplay->buswidthso I can differentiate the similarity in naming a bit more easily.
Yeah. I thought about that as well but then it takes up 3 lines... Either way is fine.
Quoted 10 lines
} else if (display->regwidth == 8 && display->buswidth == 9 && par->spi) {I'm not sure at all there is a single best style for this and it can easily become situation dependent.
And so I suggest not adding anything about this style nit to CodingStyle.
Agreed.
regards,
dan carpenter
Quoted 8 lines · Dan Carpenter
Quoted 7 lines · Joe Perches
Quoted 6 lines · Dan Carpenter
Quoted 5 lines · Luis Gerhorst
The Linux kernel coding style states that braces should only be used when necessary.
This fixes the checkpatch warning
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
WARNING: line over 80 characters
(quoted diff) +1
-0+ } else if (display->regwidth == 8 && display->buswidth == 9 && par->spi) {introduced by patch #1.
Don't introduce warnings and then fix them in later patches.
Hey Dan.
btw: I completely agree with this
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
Anyway there is another unwritten rule that multi-line indents get curly braces. Probably it should be:
Nope. That'd be your own preferred style.
I copied it from Greg so it's the subsystem style.
I don't fine any examples that match your
suggestion above in drivers/staging/fbtft.
Perhaps because there aren't many multi line
if statements.
All of the blocks that use braces are required
because one or more of the if/else blocks
contain multiple statements.
There are counterexamples in the subsystem.
cheers, Joe
Quoted 1 line
There are counterexamples in the subsystem.
Staging is essentially one giant counter example.
regards,
dan carpenter