public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: speakup: synth.c: removed a space
@ 2013-12-03 20:08 Aldo Iljazi
  2013-12-03 22:17 ` Samuel Thibault
  0 siblings, 1 reply; 8+ messages in thread
From: Aldo Iljazi @ 2013-12-03 20:08 UTC (permalink / raw)
  To: w.d.hubbs; +Cc: chris, kirk, samuel.thibault, gregkh, devel, linux-kernel

Line 468: Removed a space before a semicolon.

Signed-off-by: Aldo Iljazi <mail@aldo.io>
---
 drivers/staging/speakup/synth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 0b3549b..2a4b348 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -465,7 +465,7 @@ void synth_remove(struct spk_synth *in_synth)
 		if (in_synth == synths[i])
 			break;
 	}
-	for ( ; synths[i] != NULL; i++) /* compress table */
+	for (; synths[i] != NULL; i++) /* compress table */
 		synths[i] = synths[i+1];
 	module_status = 0;
 	mutex_unlock(&spk_mutex);
-- 
1.8.3.2


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

* Re: [PATCH] Staging: speakup: synth.c: removed a space
  2013-12-03 20:08 [PATCH] Staging: speakup: synth.c: removed a space Aldo Iljazi
@ 2013-12-03 22:17 ` Samuel Thibault
  2013-12-04  4:35   ` Aldo Iljazi
  0 siblings, 1 reply; 8+ messages in thread
From: Samuel Thibault @ 2013-12-03 22:17 UTC (permalink / raw)
  To: Aldo Iljazi; +Cc: w.d.hubbs, chris, kirk, gregkh, devel, linux-kernel

Aldo Iljazi, le Tue 03 Dec 2013 22:08:03 +0200, a écrit :
> Line 468: Removed a space before a semicolon.

Err, I'd rather make it really visible that the for loop doesn't have
its first statement?

Samuel

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

* Re: [PATCH] Staging: speakup: synth.c: removed a space
  2013-12-03 22:17 ` Samuel Thibault
@ 2013-12-04  4:35   ` Aldo Iljazi
  2013-12-04  7:38     ` Dan Carpenter
  0 siblings, 1 reply; 8+ messages in thread
From: Aldo Iljazi @ 2013-12-04  4:35 UTC (permalink / raw)
  To: Samuel Thibault, w.d.hubbs, chris, kirk, gregkh, devel,
	linux-kernel

 Samuel Thibault wrote:

> Err, I'd rather make it really visible that the for loop doesn't have
> its first statement?

Wouldn't it be better if you add a comment there? So it would follow the
coding style?
-- 
Aldo Iljazi

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

* Re: [PATCH] Staging: speakup: synth.c: removed a space
  2013-12-04  4:35   ` Aldo Iljazi
@ 2013-12-04  7:38     ` Dan Carpenter
  2013-12-04  7:45       ` Joe Perches
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Carpenter @ 2013-12-04  7:38 UTC (permalink / raw)
  To: Aldo Iljazi
  Cc: Samuel Thibault, w.d.hubbs, chris, kirk, gregkh, devel,
	linux-kernel, Joe Perches, Andy Whitcroft

On Wed, Dec 04, 2013 at 06:35:15AM +0200, Aldo Iljazi wrote:
>  Samuel Thibault wrote:
> 
> > Err, I'd rather make it really visible that the for loop doesn't have
> > its first statement?
> 
> Wouldn't it be better if you add a comment there? So it would follow the
> coding style?

No.  Adding obvious comments is more annoying than the space.

This seems like a small bug in checkpatch.pl.  Joe, the problem is this
code:

	for ( ; x; x++) {

It's complaining about the space character before the semicolon.

regards,
dan carpenter

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

* Re: [PATCH] Staging: speakup: synth.c: removed a space
  2013-12-04  7:38     ` Dan Carpenter
@ 2013-12-04  7:45       ` Joe Perches
  2013-12-04  8:21         ` Dan Carpenter
  0 siblings, 1 reply; 8+ messages in thread
From: Joe Perches @ 2013-12-04  7:45 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Aldo Iljazi, Samuel Thibault, w.d.hubbs, chris, kirk, gregkh,
	devel, linux-kernel, Andy Whitcroft

On Wed, 2013-12-04 at 10:38 +0300, Dan Carpenter wrote:
> On Wed, Dec 04, 2013 at 06:35:15AM +0200, Aldo Iljazi wrote:
> >  Samuel Thibault wrote:
> > 
> > > Err, I'd rather make it really visible that the for loop doesn't have
> > > its first statement?
> > 
> > Wouldn't it be better if you add a comment there? So it would follow the
> > coding style?
> 
> No.  Adding obvious comments is more annoying than the space.
> 
> This seems like a small bug in checkpatch.pl.  Joe, the problem is this
> code:
> 
> 	for ( ; x; x++) {
> 
> It's complaining about the space character before the semicolon.

Shrug.  checkpatch isn't and can't be perfect.

I think it's for things like

	for (;;)

and that's better than

	for ( ; ; )
or
	for ( ;; )
or
	for ( ;;)



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

* Re: [PATCH] Staging: speakup: synth.c: removed a space
  2013-12-04  7:45       ` Joe Perches
@ 2013-12-04  8:21         ` Dan Carpenter
  2013-12-04 13:47           ` [PATCH -next] checkpatch: Warn only on "space before semicolon" at end of line Joe Perches
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Carpenter @ 2013-12-04  8:21 UTC (permalink / raw)
  To: Joe Perches
  Cc: Aldo Iljazi, Samuel Thibault, w.d.hubbs, chris, kirk, gregkh,
	devel, linux-kernel, Andy Whitcroft

You and I generally agree on style preferences...  I think the warning
should be limited to grep " ;$".

I did a grep on the kernel for ' ;' and found 8000 results.  6000 of
them are caught by my semicolon before the newline rule.  The remaining
2000 are assembly, macros, and crappy for loops.

regards,
dan carpenter


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

* [PATCH -next] checkpatch: Warn only on "space before semicolon" at end of line
  2013-12-04  8:21         ` Dan Carpenter
@ 2013-12-04 13:47           ` Joe Perches
  2013-12-05  7:41             ` Dan Carpenter
  0 siblings, 1 reply; 8+ messages in thread
From: Joe Perches @ 2013-12-04 13:47 UTC (permalink / raw)
  To: Dan Carpenter, Andrew Morton
  Cc: Aldo Iljazi, Samuel Thibault, w.d.hubbs, chris, kirk, gregkh,
	devel, linux-kernel, Andy Whitcroft

The "space before a non-naked semicolon" test has
unwanted output when used in "for ( ;; )" loops.

Make the test work only on end-of-line statement
termination semicolons.

Signed-off-by: Joe Perches <joe@perches.com>
---
On Wed, 2013-12-04 at 11:21 +0300, Dan Carpenter wrote:
> You and I generally agree on style preferences...

True, and I think that's a good thing.

> I think the warning
> should be limited to grep " ;$".

Look at the output of:

$ git grep " ;" -- "*.[ch]"  | grep -w for
...

The "| wc -l" output above in -next is
1407

Which of those should not be warned on?

$ git grep " ;" -- "*.[ch]"  | grep -P "\bfor\s*\(\s+;" | wc -l
211

I think all of the uses like "for ( ; expression;  expression)"
are unbalanced and should be avoided.

<I go off and look at checkpatch output>

Oh.  checkpatch doesn't complain about spacing around
semicolon with for loops here.  This error is a separate
test that looks only for space before semicolon.

So, we agree after all.

This test should look only for space before end-of-statement
semicolons at EOL.

This has still has false positives with multi-line fors like:

	for ( ; expression ;
	     expression);

 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 38be5d5..d26eac6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3131,7 +3131,7 @@ sub process {
 		}
 
 # check for whitespace before a non-naked semicolon
-		if ($line =~ /^\+.*\S\s+;/) {
+		if ($line =~ /^\+.*\S\s+;\s*$/) {
 			if (WARN("SPACING",
 				 "space prohibited before semicolon\n" . $herecurr) &&
 			    $fix) {



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

* Re: [PATCH -next] checkpatch: Warn only on "space before semicolon" at end of line
  2013-12-04 13:47           ` [PATCH -next] checkpatch: Warn only on "space before semicolon" at end of line Joe Perches
@ 2013-12-05  7:41             ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2013-12-05  7:41 UTC (permalink / raw)
  To: Joe Perches
  Cc: Andrew Morton, devel, kirk, gregkh, linux-kernel, Aldo Iljazi,
	Andy Whitcroft, Samuel Thibault, chris

Thanks so much.  :)

regards,
dan carpenter


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

end of thread, other threads:[~2013-12-05  7:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-03 20:08 [PATCH] Staging: speakup: synth.c: removed a space Aldo Iljazi
2013-12-03 22:17 ` Samuel Thibault
2013-12-04  4:35   ` Aldo Iljazi
2013-12-04  7:38     ` Dan Carpenter
2013-12-04  7:45       ` Joe Perches
2013-12-04  8:21         ` Dan Carpenter
2013-12-04 13:47           ` [PATCH -next] checkpatch: Warn only on "space before semicolon" at end of line Joe Perches
2013-12-05  7:41             ` Dan Carpenter

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