kernel32/tests: do not compare handle with zero directly (Smatch)
Dan Carpenter
error27 at gmail.com
Tue Jan 19 05:32:55 CST 2010
Sorry, I'm not on the list.
- ok( file != 0, "CreateFileMapping PAGE_READWRITE error %u\n", GetLastError() );
+ ok( !!file, "CreateFileMapping PAGE_READWRITE error %u\n", GetLastError() );
Smatch sees those as equivelent. (The new version does at least http://repo.or.cz/w/smatch.git).
There is a wine_checker.sh script in smatch_scripts so you can quickly test
individual files. I just pushed a change to make wine_checker.sh find the
smatch binary so you may want to pull the most recent changes.
/path/to/smatch_scripts/wine_checker.sh dlls/kernel32/tests/virtual.c
Michael said it could be either real bug or a false positive. I sort of decided
it was a false positive and pushed a change to fix that. Now if "file" gets
1) reassigned
2) incremented/decremented
3) passed to a function like this: fuction(&file);
it stops being called a filehandle. (Unless it gets reassigned another file
handle obviously).
Hope that is Ok.
The check only prints a warning if something is _definitely_ a file handle and
it gets compared to zero. I could easily change it to print a message if
something is _possibly_ a file handle and gets compared against zero. Like this:
if (x)
file = CreateFile();
else
file = some_func();
if (file) // <- complain
I know smatch has been abandonware for a long time, but I hope to do better
now.
regards,
dan carpenter
More information about the wine-devel
mailing list