Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754682AbbLLBvg (ORCPT ); Fri, 11 Dec 2015 20:51:36 -0500 Received: from mail-vk0-f51.google.com ([209.85.213.51]:36559 "EHLO mail-vk0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754579AbbLLBvP (ORCPT ); Fri, 11 Dec 2015 20:51:15 -0500 MIME-Version: 1.0 In-Reply-To: <1449884094.3564.6.camel@perches.com> References: <1449864511.3564.4.camel@perches.com> <1449884094.3564.6.camel@perches.com> Date: Fri, 11 Dec 2015 22:51:15 -0300 Message-ID: Subject: Re: [BUG] checkpatch warning default switch case From: "Geyslan G. Bem" To: Joe Perches Cc: LKML , Andy Whitcroft , Peter Senna Tschudin Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2896 Lines: 104 2015-12-11 22:34 GMT-03:00 Joe Perches : > On Fri, 2015-12-11 at 18:56 -0300, Geyslan G. Bem wrote: >> 2015-12-11 17:21 GMT-03:00 Geyslan G. Bem : >> > 2015-12-11 17:08 GMT-03:00 Joe Perches : >> > > 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/