Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1289853 > unrolled thread

[BUG] checkpatch warning default switch case

Started by"Geyslan G. Bem" <geyslan@gmail.com>
First post2015-12-11 20:40 +0100
Last post2015-12-12 03:00 +0100
Articles 6 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [BUG] checkpatch warning default switch case "Geyslan G. Bem" <geyslan@gmail.com> - 2015-12-11 20:40 +0100
    Re: [BUG] checkpatch warning default switch case Joe Perches <joe@perches.com> - 2015-12-11 21:10 +0100
      Re: [BUG] checkpatch warning default switch case "Geyslan G. Bem" <geyslan@gmail.com> - 2015-12-11 21:30 +0100
        Re: [BUG] checkpatch warning default switch case "Geyslan G. Bem" <geyslan@gmail.com> - 2015-12-11 23:00 +0100
          Re: [BUG] checkpatch warning default switch case Joe Perches <joe@perches.com> - 2015-12-12 02:40 +0100
            Re: [BUG] checkpatch warning default switch case "Geyslan G. Bem" <geyslan@gmail.com> - 2015-12-12 03:00 +0100

#1289853 — [BUG] checkpatch warning default switch case

From"Geyslan G. Bem" <geyslan@gmail.com>
Date2015-12-11 20:40 +0100
Subject[BUG] checkpatch warning default switch case
Message-ID<qEBHQ-ir-9@gated-at.bofh.it>
Hello,

Running
scripts/checkpatch.pl -f drivers/usb/host/ehci-sched.c

I got this
...
ERROR: spaces required around that ':' (ctx:VxE)
#496: FILE: drivers/usb/host/ehci-sched.c:496:
+                       default:
...


496:            default:
                        ehci_dbg (ehci,
                                "periodic frame %d bogus type %d\n",
                                frame, type);
                }

It seems a correct use of default switch case. Maybe the test concerns
to ternary conditional.

Let me know.

-- 
Regards,

Geyslan G. Bem
hackingbits.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1289878

FromJoe Perches <joe@perches.com>
Date2015-12-11 21:10 +0100
Message-ID<qECaR-IL-5@gated-at.bofh.it>
In reply to#1289853
On Fri, 2015-12-11 at 16:34 -0300, Geyslan G. Bem wrote:
> Hello,
> 
> Running
> scripts/checkpatch.pl -f drivers/usb/host/ehci-sched.c
> 
> I got this
> ...
> ERROR: spaces required around that ':' (ctx:VxE)
> #496: FILE: drivers/usb/host/ehci-sched.c:496:
> +                       default:
> ...
> 
> 
> 496:            default:
>                         ehci_dbg (ehci,
>                                 "periodic frame %d bogus type %d\n",
>                                 frame, type);
>                 }
> 
> It seems a correct use of default switch case. Maybe the test concerns
> to ternary conditional.
> 
> Let me know.

Yes, it's a checkpatch defect.

It's because a c99 style comment is immediately before this line.

	switch (foo) {
	case 1:
		break;
	// foo
	default:
		break;
	}

emits this ERROR

I suggest you fix the comment and the message will go away.

Andy?  Do you care to fix this defect?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1289888

From"Geyslan G. Bem" <geyslan@gmail.com>
Date2015-12-11 21:30 +0100
Message-ID<qECue-Pv-19@gated-at.bofh.it>
In reply to#1289878
2015-12-11 17:08 GMT-03:00 Joe Perches <joe@perches.com>:
> On Fri, 2015-12-11 at 16:34 -0300, Geyslan G. Bem wrote:
>> Hello,
>>
>> Running
>> scripts/checkpatch.pl -f drivers/usb/host/ehci-sched.c
>>
>> I got this
>> ...
>> ERROR: spaces required around that ':' (ctx:VxE)
>> #496: FILE: drivers/usb/host/ehci-sched.c:496:
>> +                       default:
>> ...
>>
>>
>> 496:            default:
>>                         ehci_dbg (ehci,
>>                                 "periodic frame %d bogus type %d\n",
>>                                 frame, type);
>>                 }
>>
>> It seems a correct use of default switch case. Maybe the test concerns
>> to ternary conditional.
>>
>> Let me know.
>
> Yes, it's a checkpatch defect.
>
> It's because a c99 style comment is immediately before this line.
>
>         switch (foo) {
>         case 1:
>                 break;
>         // foo
>         default:
>                 break;
>         }
>
> emits this ERROR
>
> I suggest you fix the comment and the message will go away.
Ok, I'm fixing it.

Tks.
>
> Andy?  Do you care to fix this defect?
>



-- 
Regards,

Geyslan G. Bem
hackingbits.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1289935

From"Geyslan G. Bem" <geyslan@gmail.com>
Date2015-12-11 23:00 +0100
Message-ID<qEDTk-1BH-3@gated-at.bofh.it>
In reply to#1289888
2015-12-11 17:21 GMT-03:00 Geyslan G. Bem <geyslan@gmail.com>:
> 2015-12-11 17:08 GMT-03:00 Joe Perches <joe@perches.com>:
>> On Fri, 2015-12-11 at 16:34 -0300, Geyslan G. Bem wrote:
>>> Hello,
>>>
>>> Running
>>> scripts/checkpatch.pl -f drivers/usb/host/ehci-sched.c
>>>
>>> I got this
>>> ...
>>> ERROR: spaces required around that ':' (ctx:VxE)
>>> #496: FILE: drivers/usb/host/ehci-sched.c:496:
>>> +                       default:
>>> ...
>>>
>>>
>>> 496:            default:
>>>                         ehci_dbg (ehci,
>>>                                 "periodic frame %d bogus type %d\n",
>>>                                 frame, type);
>>>                 }
>>>
>>> It seems a correct use of default switch case. Maybe the test concerns
>>> to ternary conditional.
>>>
>>> Let me know.
>>
>> Yes, it's a checkpatch defect.
>>
>> It's because a c99 style comment is immediately before this line.
>>
>>         switch (foo) {
>>         case 1:
>>                 break;
>>         // foo
>>         default:
>>                 break;
>>         }
>>
>> emits this ERROR
>>
>> I suggest you fix the comment and the message will go away.
> Ok, I'm fixing it.
>
> Tks.
>>
>> Andy?  Do you care to fix this defect?
>>
>

Another false positive:

WARNING: braces {} are not necessary for single statement blocks
#1570: FILE: drivers/usb/host/ehci-sched.c:1570:
+               else {
+                       start = (stream->ps.phase << 3) +
stream->ps.phase_uf;
+               }

The code:

        if (stream->ps.phase == NO_FRAME) {
            int        done = 0;
...
            reserve_release_iso_bandwidth(ehci, stream, 1);
        }

        /* New stream is already scheduled; use the upcoming slot */
        else {
            start = (stream->ps.phase << 3) + stream->ps.phase_uf;
        }

There's a C89 comment before the else branch and immediately before
that an empty line. They, I think, are confusing the parser.

>
>
> --
> Regards,
>
> Geyslan G. Bem
> hackingbits.com



-- 
Regards,

Geyslan G. Bem
hackingbits.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1290058

FromJoe Perches <joe@perches.com>
Date2015-12-12 02:40 +0100
Message-ID<qEHkd-3Sf-3@gated-at.bofh.it>
In reply to#1289935
On Fri, 2015-12-11 at 18:56 -0300, Geyslan G. Bem wrote:
> 2015-12-11 17:21 GMT-03:00 Geyslan G. Bem <geyslan@gmail.com>:
> > 2015-12-11 17:08 GMT-03:00 Joe Perches <joe@perches.com>:
> > > On Fri, 2015-12-11 at 16:34 -0300, Geyslan G. Bem wrote:
> > > > Hello,
> > > > 
> > > > Running
> > > > scripts/checkpatch.pl -f drivers/usb/host/ehci-sched.c
> > > > 
> > > > I got this
> > > > ...
> > > > ERROR: spaces required around that ':' (ctx:VxE)
> > > > #496: FILE: drivers/usb/host/ehci-sched.c:496:
> > > > +                       default:
> > > > ...
> > > > 
> > > > 
> > > > 496:            default:
> > > >                         ehci_dbg (ehci,
> > > >                                 "periodic frame %d bogus type
> > > > %d\n",
> > > >                                 frame, type);
> > > >                 }
> > > > 
> > > > It seems a correct use of default switch case. Maybe the test
> > > > concerns
> > > > to ternary conditional.
> > > > 
> > > > Let me know.
> > > 
> > > Yes, it's a checkpatch defect.
> > > 
> > > It's because a c99 style comment is immediately before this line.
> > > 
> > >         switch (foo) {
> > >         case 1:
> > >                 break;
> > >         // foo
> > >         default:
> > >                 break;
> > >         }
> > > 
> > > emits this ERROR
> > > 
> > > I suggest you fix the comment and the message will go away.
> > Ok, I'm fixing it.
> > 
> > Tks.
> > > 
> > > Andy?  Do you care to fix this defect?
> > > 
> > 
> 
> Another false positive:
> 
> WARNING: braces {} are not necessary for single statement blocks
> #1570: FILE: drivers/usb/host/ehci-sched.c:1570:
> +               else {
> +                       start = (stream->ps.phase << 3) +
> stream->ps.phase_uf;
> +               }
> 
> The code:
> 
>         if (stream->ps.phase == NO_FRAME) {
>             int        done = 0;
> ...
>             reserve_release_iso_bandwidth(ehci, stream, 1);
>         }
> 
>         /* New stream is already scheduled; use the upcoming slot */
>         else {
>             start = (stream->ps.phase << 3) + stream->ps.phase_uf;
>         }
> 
> There's a C89 comment before the else branch and immediately before
> that an empty line. They, I think, are confusing the parser.

checkpatch isn't a real parser

Move the comment into the else block

	if (...) {
		...;
	} else {
		/* New stream ... */
		start = ...;
	}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1290059

From"Geyslan G. Bem" <geyslan@gmail.com>
Date2015-12-12 03:00 +0100
Message-ID<qEHDz-3ZD-1@gated-at.bofh.it>
In reply to#1290058
2015-12-11 22:34 GMT-03:00 Joe Perches <joe@perches.com>:
> On Fri, 2015-12-11 at 18:56 -0300, Geyslan G. Bem wrote:
>> 2015-12-11 17:21 GMT-03:00 Geyslan G. Bem <geyslan@gmail.com>:
>> > 2015-12-11 17:08 GMT-03:00 Joe Perches <joe@perches.com>:
>> > > On Fri, 2015-12-11 at 16:34 -0300, Geyslan G. Bem wrote:
>> > > > Hello,
>> > > >
>> > > > Running
>> > > > scripts/checkpatch.pl -f drivers/usb/host/ehci-sched.c
>> > > >
>> > > > I got this
>> > > > ...
>> > > > ERROR: spaces required around that ':' (ctx:VxE)
>> > > > #496: FILE: drivers/usb/host/ehci-sched.c:496:
>> > > > +                       default:
>> > > > ...
>> > > >
>> > > >
>> > > > 496:            default:
>> > > >                         ehci_dbg (ehci,
>> > > >                                 "periodic frame %d bogus type
>> > > > %d\n",
>> > > >                                 frame, type);
>> > > >                 }
>> > > >
>> > > > It seems a correct use of default switch case. Maybe the test
>> > > > concerns
>> > > > to ternary conditional.
>> > > >
>> > > > Let me know.
>> > >
>> > > Yes, it's a checkpatch defect.
>> > >
>> > > It's because a c99 style comment is immediately before this line.
>> > >
>> > >         switch (foo) {
>> > >         case 1:
>> > >                 break;
>> > >         // foo
>> > >         default:
>> > >                 break;
>> > >         }
>> > >
>> > > emits this ERROR
>> > >
>> > > I suggest you fix the comment and the message will go away.
>> > Ok, I'm fixing it.
>> >
>> > Tks.
>> > >
>> > > Andy?  Do you care to fix this defect?
>> > >
>> >
>>
>> Another false positive:
>>
>> WARNING: braces {} are not necessary for single statement blocks
>> #1570: FILE: drivers/usb/host/ehci-sched.c:1570:
>> +               else {
>> +                       start = (stream->ps.phase << 3) +
>> stream->ps.phase_uf;
>> +               }
>>
>> The code:
>>
>>         if (stream->ps.phase == NO_FRAME) {
>>             int        done = 0;
>> ...
>>             reserve_release_iso_bandwidth(ehci, stream, 1);
>>         }
>>
>>         /* New stream is already scheduled; use the upcoming slot */
>>         else {
>>             start = (stream->ps.phase << 3) + stream->ps.phase_uf;
>>         }
>>
>> There's a C89 comment before the else branch and immediately before
>> that an empty line. They, I think, are confusing the parser.
>
> checkpatch isn't a real parser
>
> Move the comment into the else block
>
>         if (...) {
>                 ...;
>         } else {
>                 /* New stream ... */
>                 start = ...;
>         }
>
>
Tks. Patch sent.


-- 
Regards,

Geyslan G. Bem
hackingbits.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web