- while (*lpszStr);
- while (*lpszStr)
could we catch this type of error with smatch ? A+
Eric Pouech wrote:
- while (*lpszStr);
- while (*lpszStr)
could we catch this type of error with smatch ?
hell, gcc -Wall -pedantic ought to catch it...
hell, gcc -Wall -pedantic ought to catch it...
but it catches a zillion of other (unwanted) warnings which makes it harder to catch
A+
On Mon, Mar 03, 2003 at 07:01:35PM +0100, Eric Pouech wrote:
- while (*lpszStr);
- while (*lpszStr)
could we catch this type of error with smatch ?
It's pretty easy to check for "(while|for)(....);", but the interesting part is to keep the false positive minimal. I'll see what i can do.
bye michael
Michael Stefaniuc wrote:
On Mon, Mar 03, 2003 at 07:01:35PM +0100, Eric Pouech wrote:
- while (*lpszStr);
- while (*lpszStr)
could we catch this type of error with smatch ?
It's pretty easy to check for "(while|for)(....);", but the interesting part is to keep the false positive minimal. I'll see what i can do.
look for: if (...); (while|for)(...);{ };while
should limit false positives
A+
On Mon, Mar 03, 2003 at 10:01:39PM +0100, Eric Pouech wrote:
Michael Stefaniuc wrote:
On Mon, Mar 03, 2003 at 07:01:35PM +0100, Eric Pouech wrote:
- while (*lpszStr);
- while (*lpszStr)
could we catch this type of error with smatch ?
It's pretty easy to check for "(while|for)(....);", but the interesting part is to keep the false positive minimal. I'll see what i can do.
look for: if (...); (while|for)(...);{ };while
should limit false positives
That's even easier in smatch, i have to just check for: (if|for|while)_cond end_(if|for|while)
but that's still a lot of false positives. One false positive (real code) is: while (*p++ != 0x4D && p < pend);
I need to check what's inside the () too. I'm looking at the moment at the false positives to know what to look for.
bye michael
Michael Stefaniuc a écrit:
That's even easier in smatch, i have to just check for: (if|for|while)_cond end_(if|for|while)
but that's still a lot of false positives. One false positive (real code) is: while (*p++ != 0x4D && p < pend);
I need to check what's inside the () too. I'm looking at the moment at the false positives to know what to look for.
Probably anything that changes a value (++, --, =, +=, -=, *=, /=, etc.).
But then you risk losing some real problems, as something might be correctly assigned in the condition part of a while, but with a ";" as loop instead of the real loop.
Vincent
On Mon, Mar 03, 2003 at 04:14:16PM -0500, Vincent Béron wrote:
Michael Stefaniuc a écrit:
That's even easier in smatch, i have to just check for: (if|for|while)_cond end_(if|for|while)
but that's still a lot of false positives. One false positive (real code) is: while (*p++ != 0x4D && p < pend);
I need to check what's inside the () too. I'm looking at the moment at the false positives to know what to look for.
Probably anything that changes a value (++, --, =, +=, -=, *=, /=, etc.).
That is my intention.
But then you risk losing some real problems, as something might be correctly assigned in the condition part of a while, but with a ";" as loop instead of the real loop.
Hmm ... that is also easy to check while (...); { translates into smatch: end_while cmpstmt_start
A lot of nice stuff to play with.
bye michael
Ok, i finaly got the time to finish the smatch script. It checks for "while|for (...);" constructs and would have found the bug which started this thread. It found also two possible infinite while loops: dlls/kernel/tests/thread.c line 102 dlls/winmm/mciseq/mcimidi.c line 982 but that could be also a busy loop waiting for an other thread to modify the data. For the script and mored details see http://people.redhat.com/mstefani/wine/smatch/
bye michael
On Mon, Mar 03, 2003 at 11:14:34PM +0100, Michael Stefaniuc wrote:
On Mon, Mar 03, 2003 at 04:14:16PM -0500, Vincent Béron wrote:
Michael Stefaniuc a écrit:
That's even easier in smatch, i have to just check for: (if|for|while)_cond end_(if|for|while)
but that's still a lot of false positives. One false positive (real code) is: while (*p++ != 0x4D && p < pend);
I need to check what's inside the () too. I'm looking at the moment at the false positives to know what to look for.
Probably anything that changes a value (++, --, =, +=, -=, *=, /=, etc.).
That is my intention.
But then you risk losing some real problems, as something might be correctly assigned in the condition part of a while, but with a ";" as loop instead of the real loop.
Hmm ... that is also easy to check while (...); { translates into smatch: end_while cmpstmt_start
A lot of nice stuff to play with.
bye michael
while (*p++ != 0x4D && p < pend);
It is best to add a continue to the above.
I remember one loop that ended up looking like:
while (...) do { ... } while (...);
David