[Python-Dev] Typo.pl scan of Python 2.5 source code (original) (raw)
Johnny Lee typo_pl at hotmail.com
Sat Oct 28 05:35:48 CEST 2006
- Previous message: [Python-Dev] [Python-checkins] r52482 - in python/branches/release25-maint: Lib/urllib.py Lib/urllib2.py Misc/NEWS
- Next message: [Python-Dev] build bots, log output
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I grabbed the latest Python2.5 code via subversion and ran my typo script on it.
Weeding out the obvious false positives and Neal's comments leaves about 129 typos.
See http://www.geocities.com/typopl/typoscan.htm
Should I enter the typos as bugs in the Python bug db? J
Date: Fri, 22 Sep 2006 21:51:38 -0700> From: nnorwitz at gmail.com> To: typopl at hotmail.com> Subject: Re: [Python-Dev] Typo.pl scan of Python 2.5 source code> CC: python-dev at python.org> > On 9/22/06, Johnny Lee <typopl at hotmail.com> wrote:> >> > Hello,> > My name is Johnny Lee. I have developed a ahem perl script which scans> > C/C++ source files for typos.> > Hi Johnny.> > Thanks for running your script, even if it is written in Perl and ran> on Windows. :-)> > > The Python 2.5 typos can be classified into 7 types.> >> > 2) realloc overwrite src if NULL, i.e. p = realloc(p, newsize);> > If realloc() fails, it will return NULL. If you assign the return value to> > the same variable you passed into realloc,> > then you've overwritten the variable and possibly leaked the memory that the> > variable pointed to.> > A bunch of these warnings were accurate and a bunch were not. There> were 2 reasons for the false positives. 1) The pointer was aliased,> thus not lost, 2) On failure, we exited (Parser/.c)> > > 4) if ((X!=0) || (X!=1))> > These 2 cases occurred in binascii. I have no idea if the warning is> wright or the code is.> > > 6) XX;;> > Just being anal here. Two semicolons in a row. Second one is extraneous.> > I already checked in a fix for these on HEAD. Hard for even me to> screw up those fixes. :-)> > > 7) extraneous test for non-NULL ptr> > Several memory calls that free memory accept NULL ptrs.> > So testing for NULL before calling them is redundant and wastes code space.> > Now some codepaths may be time-critical, but probably not all, and smaller> > code usually helps.> > I ignored these as I'm not certain all the platforms we run on accept> free(NULL).> > Below is my categorization of the warnings except #7. Hopefully> someone will fix all the real problems in the first batch.> > Thanks again!> > n> --> > # Problems> Objects\fileobject.c (338): realloc overwrite src if NULL; 17:> file->fsetbuf=(char)PyMemRealloc(file->fsetbuf,bufsize)> Objects\fileobject.c (342): using PyMemRealloc result w/no check> 30: setvbuf(file->ffp, file->fsetbuf, type, bufsize);> [file->fsetbuf]> Objects\listobject.c (2619): using PyMemMALLOC result w/no check> 30: garbage[i] = selfitems[cur]; [garbage]> Parser\myreadline.c (144): realloc overwrite src if NULL; 17:> p=(char*)PyMemREALLOC(p,n+incr)> Modules_csv.c (564): realloc overwrite src if NULL; 17:> self->field=PyMemRealloc(self->field,self->fieldsize)> Modules_localemodule.c (366): realloc overwrite src if NULL; 17:> buf=PyMemRealloc(buf,n2)> Modules_randommodule.c (290): realloc overwrite src if NULL; 17:> key=(unsigned#long*)PyMemRealloc(key,biggersizeof(key))> Modules\arraymodule.c (1675): realloc overwrite src if NULL; 17:> self->obitem=(char)PyMemREALLOC(self->obitem,itemsizeself->obsize)> Modules\cPickle.c (536): realloc overwrite src if NULL; 17:> self->buf=(char*)realloc(self->buf,n)> Modules\cPickle.c (592): realloc overwrite src if NULL; 17:> self->buf=(char*)realloc(self->buf,bigger)> Modules\cPickle.c (4369): realloc overwrite src if NULL; 17:> self->marks=(int*)realloc(self->marks,ssizeof(int))> Modules\cStringIO.c (344): realloc overwrite src if NULL; 17:> self->buf=(char)realloc(self->buf,self->bufsize)> Modules\cStringIO.c (380): realloc overwrite src if NULL; 17:> oself->buf=(char*)realloc(oself->buf,oself->bufsize)> Modules_ctypes_ctypes.c (2209): using PyMemMalloc result w/no> check 30: memset(obj->bptr, 0, dict->size); [obj->bptr]> Modules_ctypes\callproc.c (1472): using PyMemMalloc result w/no> check 30: strcpy(conversionmodeencoding, coding);> [conversionmodeencoding]> Modules_ctypes\callproc.c (1478): using PyMemMalloc result w/no> check 30: strcpy(conversionmodeerrors, mode);> [conversionmodeerrors]> Modules_ctypes\stgdict.c (362): using PyMemMalloc result w/no> check 30: memset(stgdict->ffitypepointer.elements, 0,> [stgdict->ffitypepointer.elements]> Modules_ctypes\stgdict.c (376): using PyMemMalloc result w/no> check 30: memset(stgdict->ffitypepointer.elements, 0,> [stgdict->ffitypepointer.elements]> > # No idea if the code or tool is right.> Modules\binascii.c (1161)> Modules\binascii.c (1231)> > # Platform specific files. I didn't review and won't fix without testing.> Python\threadlwp.h (107): using malloc result w/no check 30:> lock->locklocked = 0; [lock]> Python\threados2.h (141): using malloc result w/no check 30:> (long)sem)); [sem]> Python\threados2.h (155): using malloc result w/no check 30:> lock->isset = 0; [lock]> Python\threadpth.h (133): using malloc result w/no check 30:> memset((void *)lock, '\0', sizeof(pthlock)); [lock]> Python\threadsolaris.h (48): using malloc result w/no check 30:> funcarg->func = func; [funcarg]> Python\threadsolaris.h (133): using malloc result w/no check 30:> if(mutexinit(lock,USYNCTHREAD,0)) [lock]> > # Who cares about these modules.> Modules\almodule.c:182> Modules\svmodule.c:547> > # Not a problem.> Parser\firstsets.c (76)> Parser\grammar.c (40)> Parser\grammar.c (59)> Parser\grammar.c (83)> Parser\grammar.c (102)> Parser\node.c (95)> Parser\pgen.c (52)> Parser\pgen.c (69)> Parser\pgen.c (126)> Parser\pgen.c (438)> Parser\pgen.c (462)> Parser\tokenizer.c (797)> Parser\tokenizer.c (869)> Modules_bsddb.c (2633)> Modules_csv.c (1069)> Modules\arraymodule.c (1871)> Modules\gcmodule.c (1363)> Modules\zlib\trees.c (375)
Get the new Windows Live Messenger! http://get.live.com/messenger/overview -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20061028/46c37e2d/attachment.htm
- Previous message: [Python-Dev] [Python-checkins] r52482 - in python/branches/release25-maint: Lib/urllib.py Lib/urllib2.py Misc/NEWS
- Next message: [Python-Dev] build bots, log output
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]