mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: host: ehci-sched: silence checkpatch warning
@ 2015-12-12  1:50 Geyslan G. Bem
  2015-12-12  2:02 ` Geyslan G. Bem
  2015-12-12 16:19 ` Alan Stern
  0 siblings, 2 replies; 4+ messages in thread
From: Geyslan G. Bem @ 2015-12-12  1:50 UTC (permalink / raw)
  Cc: Geyslan G. Bem, joe, peter.senna, Alan Stern, Greg Kroah-Hartman,
	linux-usb, linux-kernel

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

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

Caught by checkpatch.

Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
Suggested-by: Joe Perches <joe@perches.com>
---
 drivers/usb/host/ehci-sched.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index f6e828a..b2af0b3 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -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;
 	}
-- 
2.6.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: host: ehci-sched: silence checkpatch warning
  2015-12-12  1:50 [PATCH] usb: host: ehci-sched: silence checkpatch warning Geyslan G. Bem
@ 2015-12-12  2:02 ` Geyslan G. Bem
  2015-12-12 16:19 ` Alan Stern
  1 sibling, 0 replies; 4+ messages in thread
From: Geyslan G. Bem @ 2015-12-12  2:02 UTC (permalink / raw)
  To: Geyslan G. Bem
  Cc: Joe Perches, Peter Senna Tschudin, Alan Stern,
	Greg Kroah-Hartman, linux-usb, LKML

2015-12-11 22:50 GMT-03:00 Geyslan G. Bem <geyslan@gmail.com>:
> This patch moves comment into the else branch avoiding the following
> misleading warning.
>
> "braces {} are not necessary for single statement blocks"
>
> Caught by checkpatch.
>
> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
> Suggested-by: Joe Perches <joe@perches.com>
> ---
>  drivers/usb/host/ehci-sched.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
> index f6e828a..b2af0b3 100644
> --- a/drivers/usb/host/ehci-sched.c
> +++ b/drivers/usb/host/ehci-sched.c
> @@ -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;
>         }
> --
> 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


-- 
Regards,

Geyslan G. Bem
hackingbits.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: host: ehci-sched: silence checkpatch warning
  2015-12-12  1:50 [PATCH] usb: host: ehci-sched: silence checkpatch warning Geyslan G. Bem
  2015-12-12  2:02 ` Geyslan G. Bem
@ 2015-12-12 16:19 ` Alan Stern
  2015-12-12 16:39   ` Geyslan G. Bem
  1 sibling, 1 reply; 4+ messages in thread
From: Alan Stern @ 2015-12-12 16:19 UTC (permalink / raw)
  To: Geyslan G. Bem
  Cc: joe, peter.senna, Greg Kroah-Hartman, linux-usb, linux-kernel

On Fri, 11 Dec 2015, Geyslan G. Bem wrote:

> This patch moves comment into the else branch avoiding the following
> misleading warning.
> 
> "braces {} are not necessary for single statement blocks"
> 
> Caught by checkpatch.
> 
> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
> Suggested-by: Joe Perches <joe@perches.com>
> ---
>  drivers/usb/host/ehci-sched.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
> index f6e828a..b2af0b3 100644
> --- a/drivers/usb/host/ehci-sched.c
> +++ b/drivers/usb/host/ehci-sched.c
> @@ -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.

>  			start = (stream->ps.phase << 3) + stream->ps.phase_uf;
>  		}
> -

Don't do this.

>  		stream->next_uframe = start;
>  		new_stream = true;
>  	}

Alan Stern


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: host: ehci-sched: silence checkpatch warning
  2015-12-12 16:19 ` Alan Stern
@ 2015-12-12 16:39   ` Geyslan G. Bem
  0 siblings, 0 replies; 4+ messages in thread
From: Geyslan G. Bem @ 2015-12-12 16:39 UTC (permalink / raw)
  To: Alan Stern
  Cc: Joe Perches, Peter Senna Tschudin, Greg Kroah-Hartman, linux-usb, LKML

Hello,

2015-12-12 13:19 GMT-03:00 Alan Stern <stern@rowland.harvard.edu>:
> On Fri, 11 Dec 2015, Geyslan G. Bem wrote:
>
>> This patch moves comment into the else branch avoiding the following
>> misleading warning.
>>
>> "braces {} are not necessary for single statement blocks"
>>
>> Caught by checkpatch.
>>
>> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
>> Suggested-by: Joe Perches <joe@perches.com>
>> ---
>>  drivers/usb/host/ehci-sched.c | 7 ++-----
>>  1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
>> index f6e828a..b2af0b3 100644
>> --- a/drivers/usb/host/ehci-sched.c
>> +++ b/drivers/usb/host/ehci-sched.c
>> @@ -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.

I see. It's particular comment style.
>
> 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.

>
>>                       start = (stream->ps.phase << 3) + stream->ps.phase_uf;
>>               }
>> -
>
> Don't do this.
>
>>               stream->next_uframe = start;
>>               new_stream = true;
>>       }
>
> Alan Stern
>



-- 
Regards,

Geyslan G. Bem
hackingbits.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-12 16:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-12  1:50 [PATCH] usb: host: ehci-sched: silence checkpatch warning Geyslan G. Bem
2015-12-12  2:02 ` Geyslan G. Bem
2015-12-12 16:19 ` Alan Stern
2015-12-12 16:39   ` Geyslan G. Bem

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®