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

[FWP] That was productive...



I was searching for a malloc smashing bug without success so I looked on
the 'net for tools to do so. In my search I came across the C FAQ that
suggested malloc(strlen(s)) as a common form of bug.

"Nah!", I thought, "Surely not, nobody would be.... Well in a million
lines of code maybe somebody has..."

I had just built a tool that sucked all the source (overnight) for the
project off NFS into one BIG file separated ###########FILENAME#########
markers. (No slow NFS access, no slow opening and closing thousands of
files)

I also had another little perl tool (called grope) that grepped through
that and printed filename:linenumber:matching line

Just a really simplistic thing to aid navigating around a large
distributed body of code.

So
  grope '[mc]alloc\s*\(\s*strlen\s*\([^\)]*\)\s*\)\s*;'
found a nice batch of silly errors for me.

So the challenge to the list is to come up with regexps that find typical
dumb errors that C/C++/Shell/Perl programmers make. 

Hmm. I wonder how many ex-C now perl programmers have written...
   for( $i = 0; $i < $#array; $i++)
instead of...
   for( $i = 0; $i <= $#array; $i++)




John Carter

Work Email : john@netsys.co.za Private email : cyent@mweb.co.za 
Yell Phone : 083-543-6915      Phone         : 27-12-348-4246



==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe