-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Turn on /analyze and fix resulting warnings #1009
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
…ant' by making the constant comparison constexpr.
StephanTLavavej
left a comment
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.
The arm/arm64 builds are failing. From the error log:
C:\agent\_work\1\s\stl\src\winapisupp.cpp(493,1): error C2220: the following warning is treated as an error
C:\agent\_work\1\s\stl\src\winapisupp.cpp(490) : warning C28251: Inconsistent annotation for '__crtQueueUserWorkItem': this instance has no annotations. See c:\agent\_work\1\s\stl\src\awint.hpp(232).
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
(In fact I'd rather this land after the atomic wait stuff since that adds new APIs that are likely to make PREfast unhappy) |
And follow the style in threadpoollegacyapiset.h.
The functional changes are: * `__crtFlsAlloc`: Change `lpCallback` from `__in` to `_In_opt_` as declared in `fibersapi.h` * `__crtCreateEventExW`: Change `dwFlags` from `__reserved` to `_In_` as declared in `synchapi.h` * `__crtGetFileInformationByHandleEx`: Change `lpFileInformation` from `_Out_` to `_Out_writes_bytes_(dwBufferSize)` as declared in `WinBase.h` * `__crtSetFileInformationByHandle`: Change `lpFileInformation` from `_In_` to `_In_reads_bytes_(dwBufferSize)` as declared in `fileapi.h` * `__crtGetLocaleInfoEx`: Change `lpLCData` from `_Out_opt_` to `_Out_writes_opt_(cchData)` as declared in `WinNls.h`
|
Building with |
Sure, we can do that; I didn't bother before because I figure our test pass takes ~an hour and our build takes ~30 seconds, and turning this on makes it take ~45 seconds; but the test pass still dominates. Making it a CMake configurable option is probably a good idea. |
|
Pushed a fix for the build break, which was simple - define I ran full clean builds of x86/x64/arm/arm64 and they succeeded. |
|
Thanks for running that down Stephan :D |
Fixed build break, need to actually review changes now
# Conflicts: # stl/inc/xfilesystem_abi.h # stl/src/filesystem.cpp
This comment has been minimized.
This comment has been minimized.
|
I resolved the merge conflict; the code in |
|
Thanks STL |
StephanTLavavej
left a comment
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.
Only change requested is to make the /analyze build off by default, and enabled for PR/CI builds.
|
Thanks Curtis! |
|
I'm not sure how to verify that the changes I made make |
Temporarily Inject a code pattern that |
|
The build break was that |
|
Analyzing change... 🤖 Beep! Thanks for this improvement, human! 🚀 |
This is to resolve Microsoft-internal:
(which all boil down to 'getting yelled at for not turning on
/analyze')Functional changes:
_Analysis_assume_s_Out_, I removed the annotation as the annotations to tell PREfast that the parameter is conditionally_Out_exceed any value they might give us._MP_Rem__crtInitializeCriticalSectionExto return the value ofInitializeCriticalSectionAndSpinCountrather than always returnTRUE; in Vista or later this is no functional change, and on XP it will pass through the result correctly. Most callers are still ignoring the return value (as they probably should, now) but this avoids a warning here._Wcsxfrmto use RAII to record whenbbufferis allocated rather than extra null checks.Xp_setwto hoist constexpr comparisons into anif constexprblock._PThrownull check before callingRtlPcToFileHeaderin excptptr.cpp.