Re: Checkpatch.pl generates false alarm

Andy Whitcroft
2011-07-12T08:03:37Z

On Mon, Jul 11, 2011 at 09:23:26PM -0700, Joe Perches wrote:
> On Mon, 2011-07-11 at 16:48 +0200, Roland Vossen wrote:
> > Hello Andy,
> >
> > when I feed attached file to checkpatch, several warnings are given, but
> > this one:
> >
> > WARNING: externs should be avoided in .c files
> > #3555: FILE: staging/brcm80211/brcmsmac/main.c:3555:
> > + END_FOREACH_BSS
> >
> > does not seem to make sense. When I place a comment behind the
> > END_FOREACH_BSS line, the checkpatch warning disappears.
> >
> > Let me know if you need additional info to work on this.
>
> I think this code is bad form and confuses checkpatch:
>
> /* update the capability based on current shortslot mode */
> FOREACH_BSS(wlc, idx, cfg)
> if (!cfg->associated)
> continue;
> cfg->current_bss->capability &=
> ~WLAN_CAPABILITY_SHORT_SLOT_TIME;
> if (wlc->shortslot)
> cfg->current_bss->capability |=
> WLAN_CAPABILITY_SHORT_SLOT_TIME;
> END_FOREACH_BSS
>
> I think this code is still slightly bad form, but it isn't a problem
> for checkpatch:
>
> /* update the capability based on current shortslot mode */
> FOREACH_BSS(wlc, idx, cfg) {
> if (!cfg->associated)
> continue;
> cfg->current_bss->capability &=
> ~WLAN_CAPABILITY_SHORT_SLOT_TIME;
> if (wlc->shortslot)
> cfg->current_bss->capability |=
> WLAN_CAPABILITY_SHORT_SLOT_TIME;
> } END_FOREACH_BSS

Yeah I can only concur that this is the more normal form for such fake
loop structures which needs begins and ends. I don't think we are going
to be able to trivially figure out this is a loop otherwise.

-apw