Re: [PATCH] checkpatch: Warn on macros with flow control statements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2014-09-10 at 16:06 +0200, Julia Lawall wrote:
> On Wed, 10 Sep 2014, Joe Perches wrote:
> > On Wed, 2014-09-10 at 11:43 +0300, Dan Carpenter wrote:
> > > On Tue, Sep 09, 2014 at 01:38:13PM -0700, Joe Perches wrote:
> > > > Macros with flow control statements (goto and return) are
> > > > not very nice to read as any flow movement is unexpected.
> >
> > break and continue are also flow control statements
> > but are those are frequently used in macros in
> > complete switch statements so were not added.
> 
> Would it be possible to make a warning when there is a break or continue
> but no while/switch/etc.

I suppose the has_flow_statement could be extended.

Maybe something like:

			if ($ctx =~ /\b(goto|return|break|continue)\b/ &&
			    $ctx !~ /\b(switch|if|do|while)\b/) {
				has_flow_statement = 1;
			}

but checkpatch isn't really capable  of doing proper
flow logic analysis.

I'm not sure it's worthwhile.



_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux