linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] dvb-frontends: remove unnecessary break after goto
@ 2014-07-08 17:23 Fabian Frederick
  2014-07-08 18:35 ` Antti Palosaari
  0 siblings, 1 reply; 4+ messages in thread
From: Fabian Frederick @ 2014-07-08 17:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Fabian Frederick, Antti Palosaari, Mauro Carvalho Chehab, linux-media

Cc: Antti Palosaari <crope@iki.fi>
Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: linux-media@vger.kernel.org
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 drivers/media/dvb-frontends/af9013.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/af9013.c b/drivers/media/dvb-frontends/af9013.c
index fb504f1..ecf6388 100644
--- a/drivers/media/dvb-frontends/af9013.c
+++ b/drivers/media/dvb-frontends/af9013.c
@@ -470,7 +470,6 @@ static int af9013_statistics_snr_result(struct dvb_frontend *fe)
 		break;
 	default:
 		goto err;
-		break;
 	}
 
 	for (i = 0; i < len; i++) {
-- 
1.8.4.5


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

* Re: [PATCH 1/1] dvb-frontends: remove unnecessary break after goto
  2014-07-08 17:23 [PATCH 1/1] dvb-frontends: remove unnecessary break after goto Fabian Frederick
@ 2014-07-08 18:35 ` Antti Palosaari
  2014-07-09  2:12   ` Fabian Frederick
  0 siblings, 1 reply; 4+ messages in thread
From: Antti Palosaari @ 2014-07-08 18:35 UTC (permalink / raw)
  To: Fabian Frederick, linux-kernel; +Cc: Mauro Carvalho Chehab, linux-media

Moikka Fabian!
I have no reason to decline that patch (I will apply it) even it has 
hardly meaning. But is there now some new tool which warns that kind of 
issues?

regards
Atnti


On 07/08/2014 08:23 PM, Fabian Frederick wrote:
> Cc: Antti Palosaari <crope@iki.fi>
> Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>
> Cc: linux-media@vger.kernel.org
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
>   drivers/media/dvb-frontends/af9013.c | 1 -
>   1 file changed, 1 deletion(-)
>
> diff --git a/drivers/media/dvb-frontends/af9013.c b/drivers/media/dvb-frontends/af9013.c
> index fb504f1..ecf6388 100644
> --- a/drivers/media/dvb-frontends/af9013.c
> +++ b/drivers/media/dvb-frontends/af9013.c
> @@ -470,7 +470,6 @@ static int af9013_statistics_snr_result(struct dvb_frontend *fe)
>   		break;
>   	default:
>   		goto err;
> -		break;
>   	}
>
>   	for (i = 0; i < len; i++) {
>

-- 
http://palosaari.fi/

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

* [PATCH] checkpatch: Warn on break after goto or return with same tab indentation
  2014-07-09  2:12   ` Fabian Frederick
@ 2014-07-08 19:57     ` Joe Perches
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2014-07-08 19:57 UTC (permalink / raw)
  To: Andrew Morton, Fabian Frederick
  Cc: Antti Palosaari, linux-kernel, Mauro Carvalho Chehab,
	linux-media, Andy Whitcroft

Using break; after a goto or return is unnecessary so
emit a warning when the break is at the same indent level.

So this emits a warning on:

	switch (foo) {
	case 1:
		goto err;
		break;
	}

but not on:

	switch (foo) {
	case 1:
		if (bar())
			goto err;
		break;
	}

Signed-off-by: Joe Perches <joe@perches.com>
---
> AFAIK there's still no automatic detection of those cases.

There can be now...

 scripts/checkpatch.pl | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 496f9ab..fc22f22 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2439,6 +2439,16 @@ sub process {
 			}
 		}
 
+# check indentation of a line with a break;
+# if the previous line is a goto or return and is indented the same # of tabs
+		if ($sline =~ /^\+([\t]+)break\s*;\s*$/) {
+			my $tabs = $1;
+			if ($prevline =~ /^\+$tabs(?:goto|return)\b/) {
+				WARN("UNNECESSARY_BREAK",
+				     "break is not useful after a goto or return\n" . $hereprev);
+			}
+		}
+
 # discourage the addition of CONFIG_EXPERIMENTAL in #if(def).
 		if ($line =~ /^\+\s*\#\s*if.*\bCONFIG_EXPERIMENTAL\b/) {
 			WARN("CONFIG_EXPERIMENTAL",



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

* Re: [PATCH 1/1] dvb-frontends: remove unnecessary break after goto
  2014-07-08 18:35 ` Antti Palosaari
@ 2014-07-09  2:12   ` Fabian Frederick
  2014-07-08 19:57     ` [PATCH] checkpatch: Warn on break after goto or return with same tab indentation Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Fabian Frederick @ 2014-07-09  2:12 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-kernel, Mauro Carvalho Chehab, linux-media

On Tue, 08 Jul 2014 21:35:58 +0300
Antti Palosaari <crope@iki.fi> wrote:

> Moikka Fabian!
> I have no reason to decline that patch (I will apply it) even it has 
> hardly meaning. But is there now some new tool which warns that kind of 
> issues?
Hello Antti,

	Thanks :) AFAIK there's still no automatic detection of those cases.

Regards,
Fabian
> 
> regards
> Atnti
> 
> 
> On 07/08/2014 08:23 PM, Fabian Frederick wrote:
> > Cc: Antti Palosaari <crope@iki.fi>
> > Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>
> > Cc: linux-media@vger.kernel.org
> > Signed-off-by: Fabian Frederick <fabf@skynet.be>
> > ---
> >   drivers/media/dvb-frontends/af9013.c | 1 -
> >   1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/media/dvb-frontends/af9013.c b/drivers/media/dvb-frontends/af9013.c
> > index fb504f1..ecf6388 100644
> > --- a/drivers/media/dvb-frontends/af9013.c
> > +++ b/drivers/media/dvb-frontends/af9013.c
> > @@ -470,7 +470,6 @@ static int af9013_statistics_snr_result(struct dvb_frontend *fe)
> >   		break;
> >   	default:
> >   		goto err;
> > -		break;
> >   	}
> >
> >   	for (i = 0; i < len; i++) {
> >
> 
> -- 
> http://palosaari.fi/

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

end of thread, other threads:[~2014-07-08 19:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-08 17:23 [PATCH 1/1] dvb-frontends: remove unnecessary break after goto Fabian Frederick
2014-07-08 18:35 ` Antti Palosaari
2014-07-09  2:12   ` Fabian Frederick
2014-07-08 19:57     ` [PATCH] checkpatch: Warn on break after goto or return with same tab indentation Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).