-
Notifications
You must be signed in to change notification settings - Fork 1.7k
CPP: Permit more typedefs in WrongTypeFormatArguments.ql #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Sorry, messed up my mentions. Should be @nickrolfe @jbj @felicity-semmle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a lot of results going away. Is the idea that we won't report a mismatch when the types have the same unspecified type even though their unspecified types may not coincide on other platforms?
I look forward to seeing the query differences results.
The short answer is yes. It seems we need to give developers more benefit of doubt than we already were doing. The long answer: The query has a notion of the 'expected' type of a format argument, which is usually a primitive type such as However in some cases the expected type is itself a typedef - a common case being
In the above case we would have accepted only a After the change we also accept
I believe this pattern was responsible for quite a lot of false positive results, and blocking it will only hide a small number of interesting results (over-represented in the tests). The query differences should hopefully confirm this.
Me too, my first few attempts failed but I'm still hoping to produce them. |
Did you make the same mistake I made in #202 (comment)? |
No, I think I pushed code that pointed to a ql submodule I hadn't pushed. |
918d743
to
d975c09
Compare
Any luck with CPP-Differences? |
Query differences, at last! https://jenkins.internal.semmle.com/job/Query-Changes/job/CPP-Differences/456/ Most of the changes seem to be where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the query differences are about %zd
used where it should have been %zu
. You're right that the query was always supposed to allow this, but apparently it wasn't working for ssize_t
.
Fix type access extraction in field declarations
Adds a test for the
WrongTypeFormatArguments.ql
issue found earlier this week by @nick. The fix is to make the query a lot less picky about unspecified types - for example:(Nick's example looks very different but is also about underlying types of
typedef
s)This is something I've been thinking about doing for a while. It reduces the noise caused by results that, while somewhat questionable in theory, are likely OK in practice and are typically caused by combining different pieces of code that use different typedefs. The change also makes the query logic simpler (though there's still a lot to be done in that regard).
I'm going to try and run query differences on this.
@jonas - it will be good to get in before I make a PR for the
char16_t
issues with the same query. There's some crossover in real world results between the two issues that confuses things without this change.@Felicity - please check whether I've done the right thing with the change note.