Skip to contentSkip to conversation

drivers/auxdisplay: TRIVIAl removed unnessecary braces from if statements

PATCH Miguel Ojeda 2 participants 2 messages Sep 23, 2018 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hi Ben,

Quoted 39 lines · On Sun, Sep 23, 2018 at 4:33 PM, <[email protected]> wrote:

From: Ben Moore <[email protected]>

removed braches from single line if statements

---
 drivers/auxdisplay/panel.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/auxdisplay/panel.c +3 -6
index 3b25a643058c..0e4a7260dcc0 100644
@@ -695,11 +695,10 @@ static void lcd_send_serial(int byte)
        for (bit = 0; bit < 8; bit++) {
                clear_bit(LCD_BIT_CL, bits);    /* CLK low */
                panel_set_bits();
-               if (byte & 1) {
+               if (byte & 1)
                        set_bit(LCD_BIT_DA, bits);
-               } else {
+               else
                        clear_bit(LCD_BIT_DA, bits);
-               }
 
                panel_set_bits();
                udelay(2);  /* maintain the data during 2 us before CLK up */
@@ -1025,9 +1024,8 @@ static void lcd_init(void)
                        lcd.pins.rs = DEFAULT_LCD_PIN_RS;
                if (lcd.pins.rw == PIN_NOT_SET)
                        lcd.pins.rw = DEFAULT_LCD_PIN_RW;
-       } else {
+       } else
                charlcd->ops = &charlcd_tilcd_ops;
-       }
 
        if (lcd.pins.bl == PIN_NOT_SET)
                lcd.pins.bl = DEFAULT_LCD_PIN_BL;
--
Quoted 2 lines

2.11.0

A few more things (Ben's first patch, sent to me first in private):

* The subject could be better as:

[PATCH TRIVIAL] auxdisplay: remove unnecessary braces

i.e. TRIVIAL inside the [...] (which will not appear in the Git
commit message); unnessecary -> unnecessary; drivers/auxdisplay -> auxdisplay

* The commit message body ("removed braches from single line if
statements") is redundant with the title of the commit (and has the typo "braches"). You could say, instead, say something like "No functional changes."; or if you tested that it generates the same object file, something like "Tested, no codegen changes."; etc.

* You can remove the "From:" line.

* I think Willy uses the [email protected] address nowadays.

* It would be great if you can try to look for similar instances in
drivers/auxdisplay/* and send a v2 of the patch (you would need to say in the subject "[PATCH v2 TRIVIAL]").

* Don't forget to Cc the general linux-kernel mailing list, please!

Thank again for the patch and welcome to the kernel!

[Jiri, I can pick the v2 of this in my tree if you prefer.]

Cheers,
Miguel

#2 lore raw

Hi Ben,

Quoted 6 lines · Miguel Ojeda
Quoted 5 lines · On Sun, Sep 23, 2018 at 4:33 PM, <[email protected]> wrote:

From: Ben Moore <[email protected]>

removed braches from single line if statements

Thanks for you patch!

Quoted 14 lines
Quoted 14 lines
drivers/auxdisplay/panel.c +2 -3
@@ -695,11 +695,10 @@ static void lcd_send_serial(int byte)
        for (bit = 0; bit < 8; bit++) {
                clear_bit(LCD_BIT_CL, bits);    /* CLK low */
                panel_set_bits();
-               if (byte & 1) {
+               if (byte & 1)
                        set_bit(LCD_BIT_DA, bits);
-               } else {
+               else
                        clear_bit(LCD_BIT_DA, bits);
-               }
 
Quoted 10 lines

drivers/auxdisplay/panel.c static void lcd_init(void) · line 1030

Quoted 10 lines
drivers/auxdisplay/panel.c +1 -2
                panel_set_bits();
                udelay(2);  /* maintain the data during 2 us before CLK up */
@@ -1025,9 +1024,8 @@ static void lcd_init(void)
                        lcd.pins.rs = DEFAULT_LCD_PIN_RS;
                if (lcd.pins.rw == PIN_NOT_SET)
                        lcd.pins.rw = DEFAULT_LCD_PIN_RW;
-       } else {
+       } else
                charlcd->ops = &charlcd_tilcd_ops;
-       }

Please keep braces for single-statement branches if the other branch needs the braces.

I think running scripts/checkpatch.pl on your patch would tell you about that rule.

Thanks!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds