The use of a zero flag

Francois Gouget fgouget at free.fr
Thu Jan 13 04:46:14 CST 2005


On Wed, 12 Jan 2005, Dimitrie O. Paun wrote:

> On Wed, Jan 12, 2005 at 09:04:20PM +0100, Paul Vriens wrote:
>> Is it worthwhile to set up a Janitorial task for this or are these plain
>> bugs? On the one hand it will be hard to find these and you have to know
>> the code of course.
>
> Yeah, I think it's worthwhile to look at such cases, but I don't
> think we should have a janitorial task for them: they are far and
> few in between, hard to find, etc.

Actually it's not that hard. You can even do it with a one-line bash 
script:


regexp=`sed -e 's/^ *# *define *\([a-zA-Z_][a-zA-Z0-9_]*\) *0 *$/\1/' -e 't' -e 's/^ *# *define *\([a-zA-Z_][a-zA-Z0-9_]*\) *0x00*L* *$/\1/' -e 't' -e 'd' include/*.h`;regexp=`echo $regexp | sed -e 's/ NULL / /' -e 's/ /|/g'`;egrep -r -n "& *($regexp)[^a-zA-Z0-9_]" .

Ok, it's a long line but it's just one line anyway<g>.
Here's what I get:

./dlls/comctl32/listview.c:6297:        if (nColumn == 0 || lpColumn->fmt & LVCFMT_LEFT)
./dlls/comctl32/pager.c:844:    if (!(dwStyle & PGS_HORZ) && !(dwStyle & PGS_VERT))
./dlls/commdlg/filedlgbrowser.c:320:    (wFlags & SBSP_ABSOLUTE) ? "SBSP_ABSOLUTE" : "SBPS_????");
./dlls/dplayx/dplay.c:1164:  if( ( dwFlags & DPSET_REMOTE ) &&
./dlls/dplayx/dplay.c:1180:    if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:1363:  if( ( dwFlags & DPSET_REMOTE ) &&
./dlls/dplayx/dplay.c:1379:    if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:2430:  if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:2635:  if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:3061:  if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:3074:  if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:3159:  if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:3169:  if( dwFlags & DPSET_REMOTE )
./dlls/winmm/mciseq/mcimidi.c:1359:     if (lpParms->dwAudio & MCI_SET_AUDIO_ALL)
./dlls/winmm/mciwave/mciwave.c:1233:    if (lpParms->dwAudio & MCI_SET_AUDIO_ALL)


False positives:
./dlls/psapi/tests/module.c:95:    ok((retval && ERROR_SUCCESS == GetLastError()) ||
./dlls/psapi/tests/module.c:119:    ok( (retval && ERROR_SUCCESS == GetLastError()) ||


-- 
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
                 Linux: It is now safe to turn on your computer.



More information about the wine-devel mailing list