Skip to contentSkip to conversation

usb: host: ehci-sched: silence checkpatch warning

PATCH In review Geyslan G. Bem 2 participants 4 messages Dec 12, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: host: ehci-sched: silence checkpatch warning

This patch moves comment into the else branch avoiding the following misleading warning.

"braces {} are not necessary for single statement blocks"

Caught by checkpatch.

---
 drivers/usb/host/ehci-sched.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/usb/host/ehci-sched.c +2 -5
index f6e828a..b2af0b3 100644
@@ -1560,13 +1560,10 @@ iso_stream_schedule(
 					(stream->ps.bw_period - 1);
 			stream->ps.phase_uf = start & 7;
 			reserve_release_iso_bandwidth(ehci, stream, 1);
-		}
-
-		/* New stream is already scheduled; use the upcoming slot */
-		else {
+		} else {
+			/* New stream is already scheduled; use the upcoming slot */
 			start = (stream->ps.phase << 3) + stream->ps.phase_uf;
 		}
-
 		stream->next_uframe = start;
 		new_stream = true;
 	}
Signature · 1 line
2.6.3
#1 lore raw

2015-12-11 22:50 GMT-03:00 Geyslan G. Bem <[email protected]>:

Quoted 34 lines

This patch moves comment into the else branch avoiding the following misleading warning.

"braces {} are not necessary for single statement blocks"

Caught by checkpatch.

---
 drivers/usb/host/ehci-sched.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/usb/host/ehci-sched.c +2 -6
index f6e828a..b2af0b3 100644
@@ -1560,13 +1560,10 @@ iso_stream_schedule(
                                        (stream->ps.bw_period - 1);
                        stream->ps.phase_uf = start & 7;
                        reserve_release_iso_bandwidth(ehci, stream, 1);
-               }
-
-               /* New stream is already scheduled; use the upcoming slot */
-               else {
+               } else {
+                       /* New stream is already scheduled; use the upcoming slot */
                        start = (stream->ps.phase << 3) + stream->ps.phase_uf;
                }
-
                stream->next_uframe = start;
                new_stream = true;
        }
--
Quoted 2 lines

2.6.3

This one must be applied only after the bunch [PATCH 00/10] usb: host:
ehci-sched: cleanup
https://lkml.org/lkml/2015/12/11/940

Signature · 4 lines
Regards,

Geyslan G. Bem
hackingbits.com
maintainer
#2 lore raw
In reply to Geyslan G. Bem
Quoted 18 lines · Geyslan G. Bem

This patch moves comment into the else branch avoiding the following misleading warning.

"braces {} are not necessary for single statement blocks"

Caught by checkpatch.

---
 drivers/usb/host/ehci-sched.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/usb/host/ehci-sched.c +0 -0
index f6e828a..b2af0b3 100644

drivers/usb/host/ehci-sched.c iso_stream_schedule( · line 1564

Quoted 9 lines
drivers/usb/host/ehci-sched.c +2 -4
@@ -1560,13 +1560,10 @@ iso_stream_schedule(
 					(stream->ps.bw_period - 1);
 			stream->ps.phase_uf = start & 7;
 			reserve_release_iso_bandwidth(ehci, stream, 1);
-		}
-
-		/* New stream is already scheduled; use the upcoming slot */
-		else {
+		} else {
+			/* New stream is already scheduled; use the upcoming slot */

Please don't do this. The comment at the start of the "if" part of this statement comes before the "if" line, so the commend at the start of the "else" part should come before the "else" line.

If you want to silence the warning about unnecessary braces, get rid of the braces.

drivers/usb/host/ehci-sched.c iso_stream_schedule( · line 1569

Quoted 3 lines
drivers/usb/host/ehci-sched.c +0 -1
 			start = (stream->ps.phase << 3) + stream->ps.phase_uf;
 		}
-

Don't do this.

drivers/usb/host/ehci-sched.c iso_stream_schedule( · line 1569

Quoted 3 lines
drivers/usb/host/ehci-sched.c +0 -0
 		stream->next_uframe = start;
 		new_stream = true;
 	}

Alan Stern

#3 lore raw

Hello,

2015-12-12 13:19 GMT-03:00 Alan Stern <[email protected]>:

Quoted 25 lines · Geyslan G. Bem
Quoted 24 lines

This patch moves comment into the else branch avoiding the following misleading warning.

"braces {} are not necessary for single statement blocks"

Caught by checkpatch.

---
 drivers/usb/host/ehci-sched.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/usb/host/ehci-sched.c +0 -2
index f6e828a..b2af0b3 100644
@@ -1560,13 +1560,10 @@ iso_stream_schedule(
                                      (stream->ps.bw_period - 1);
                      stream->ps.phase_uf = start & 7;
                      reserve_release_iso_bandwidth(ehci, stream, 1);
-             }
-
Quoted 8 lines

drivers/usb/host/ehci-sched.c iso_stream_schedule( · line 1564

Quoted 4 lines
drivers/usb/host/ehci-sched.c +2 -2
-             /* New stream is already scheduled; use the upcoming slot */
-             else {
+             } else {
+                     /* New stream is already scheduled; use the upcoming slot */

Please don't do this. The comment at the start of the "if" part of this statement comes before the "if" line, so the commend at the start of the "else" part should come before the "else" line.

I see. It's particular comment style.

Quoted 3 lines

If you want to silence the warning about unnecessary braces, get rid of the braces.

Well, this is a particular case of checkpatch due it think that the if block has a single statement. But it's not true.

Please see:
[BUG] checkpatch warning default switch case
https://lkml.org/lkml/2015/12/11/836

So removing the braces breaks the coding style.

Quoted 13 lines

drivers/usb/host/ehci-sched.c iso_stream_schedule( · line 1569

Quoted 4 lines
drivers/usb/host/ehci-sched.c +0 -1
                      start = (stream->ps.phase << 3) + stream->ps.phase_uf;
              }
-

Don't do this.

drivers/usb/host/ehci-sched.c iso_stream_schedule( · line 1569

Quoted 3 lines
drivers/usb/host/ehci-sched.c +0 -0
              stream->next_uframe = start;
              new_stream = true;
      }

Alan Stern

Signature · 4 lines
Regards,

Geyslan G. Bem
hackingbits.com