Re: Don't compare file handles to NULL

2007-03-09 Thread Francois Gouget
On Fri, 9 Mar 2007, Michael Stefaniuc wrote: [...] > Ok, as there are no false positives i have improved the script a little; > documented it on my Smatch page and added it to my daily Smatch run. Thanks a lot for the Smatch script. It has proven pretty useful already. -- Francois Gouget <[EMAIL

Re: Don't compare file handles to NULL

2007-03-09 Thread Michael Stefaniuc
Alexandre Julliard wrote: > Michael Stefaniuc <[EMAIL PROTECTED]> writes: > >> Ok, as there are no false positives i have improved the script a little; >> documented it on my Smatch page and added it to my daily Smatch run. >> If you know more functions that return a file_handle i can search for >

Re: Don't compare file handles to NULL

2007-03-09 Thread Alexandre Julliard
Michael Stefaniuc <[EMAIL PROTECTED]> writes: > Ok, as there are no false positives i have improved the script a little; > documented it on my Smatch page and added it to my daily Smatch run. > If you know more functions that return a file_handle i can search for > those too. At the moment i'm loo

Re: Don't compare file handles to NULL

2007-03-09 Thread Michael Stefaniuc
Michael Stefaniuc wrote: > Francois Gouget wrote: > >>On Wed, 7 Mar 2007, Michael Stefaniuc wrote: >>[...] >>Sending patches... > > Send a patch too for the additional occurence that the improved script > has found. Duh ... I mean I have sent a patch already for the additional bug found by the i

Re: Don't compare file handles to NULL

2007-03-09 Thread Michael Stefaniuc
Francois Gouget wrote: > On Wed, 7 Mar 2007, Michael Stefaniuc wrote: > [...] > >>You mean something like >>http://people.redhat.com/mstefani/wine/smatch/scripts/file_handles.pl ? > > > Cool, thanks. > > > [...] > >>Most are false positives (non NULL check before CloseHandle()). > > > These

Re: Don't compare file handles to NULL

2007-03-08 Thread João Eiras
Na , Alexandre Julliard <[EMAIL PROTECTED]> escreveu: Francois Gouget <[EMAIL PROTECTED]> writes: These are not false positives. Any file handle that is not INVALID_HANDLE_VALUE must be closed with CloseHandle(). So these checks should be against INVALID_HANDLE_VALUE, not NULL. In fact they ma

Re: Don't compare file handles to NULL

2007-03-08 Thread Francois Gouget
On Thu, 8 Mar 2007, Alexandre Julliard wrote: [...] > Sure, it's best to avoid closing an invalid handle. We don't throw an > exception but we do set last error, and this could conceivably break > something. But the NULL check is not going to cause us to forget to > close a valid handle, which woul

Re: Don't compare file handles to NULL

2007-03-08 Thread Alexandre Julliard
Francois Gouget <[EMAIL PROTECTED]> writes: > On Thu, 8 Mar 2007, Alexandre Julliard wrote: > [...] >> Note that a valid file handle will never be NULL, so while these >> checks are wrong in theory, in practice it makes no difference. > > Right. But the invalid check means that in some cases we wi

Re: Don't compare file handles to NULL

2007-03-08 Thread Francois Gouget
On Thu, 8 Mar 2007, Alexandre Julliard wrote: [...] > Note that a valid file handle will never be NULL, so while these > checks are wrong in theory, in practice it makes no difference. Right. But the invalid check means that in some cases we will call CloseHandle(INVALID_HANDLE_VALUE) which the M

Re: Don't compare file handles to NULL

2007-03-08 Thread Michael Stefaniuc
Alexandre Julliard wrote: > Francois Gouget <[EMAIL PROTECTED]> writes: > > >>These are not false positives. Any file handle that is not >>INVALID_HANDLE_VALUE must be closed with CloseHandle(). So these checks >>should be against INVALID_HANDLE_VALUE, not NULL. In fact they may >>possibly be

Re: Don't compare file handles to NULL

2007-03-08 Thread Alexandre Julliard
Francois Gouget <[EMAIL PROTECTED]> writes: > These are not false positives. Any file handle that is not > INVALID_HANDLE_VALUE must be closed with CloseHandle(). So these checks > should be against INVALID_HANDLE_VALUE, not NULL. In fact they may > possibly be removed altogether. Note that a

Re: Don't compare file handles to NULL

2007-03-08 Thread Francois Gouget
On Wed, 7 Mar 2007, Michael Stefaniuc wrote: [...] > You mean something like > http://people.redhat.com/mstefani/wine/smatch/scripts/file_handles.pl ? Cool, thanks. [...] > Most are false positives (non NULL check before CloseHandle()). These are not false positives. Any file handle that is not

Re: Don't compare file handles to NULL

2007-03-07 Thread Michael Stefaniuc
Francois Gouget wrote: > Jacek just sent a patch fixing the following bug: > > file = CreateFileW(fileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, > FILE_ATTRIBUTE_READONLY,NULL); > -if(file) { > +if(file != INVALID_HANDLE_VALUE) { > > This looks like something that could be turned i

Don't compare file handles to NULL

2007-03-07 Thread Francois Gouget
Jacek just sent a patch fixing the following bug: file = CreateFileW(fileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY,NULL); -if(file) { +if(file != INVALID_HANDLE_VALUE) { This looks like something that could be turned into a nice Smatch test. Hint, hint...