As asked in the title:
What is the purpose of SAL (Source Annotation Language) and what is the difference between SAL 1 and SAL 2?
I understand the basics of the usage, and that is serves to highlight the purpose of each of the variables passed to functions along with various other things for static code analysis, but how much difference does it actually make (ignoring increasing clarity of parameter requirements for other programmers on the project)?
If I was to have the following prototype:
_Success_(return == 1)
int TestFunction( _In_ int* pTest, _Inopt_ char* pOptional );
This is supposed to "tell" the static analyser that the function will return 1 upon it's successful operation, that pTest
is a pointer which must not be nullptr
and that pOptional
is a pointer which may or may not be nullptr
. However, can't the static analyser get this information from the function definition itself? Moreover, what does it do with the information it gets such as the success criteria?
Furthermore, why is there a difference between SAL 1 and SAL 2, why did microsoft decide to change the way they named their macros (i.e. from __out
to _Out_
and __success
to _Success_
?)
I'm sorry if this is described somewhere in detail on the MSDN but I was unable to find it or any other question on StackOverflow with a detailed answer so I thought I'd ask in the hopes of having my curiosity satisfied.
Thanks in advance for your time!