Questions tagged [sal]

SAL is the Microsoft language for static analysis of C++ source code.

More details on SAL can be found at https://learn.microsoft.com/en-us/visualstudio/code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects.

52 questions
1
vote
1 answer

Code analysis doesn't understand _In_opt_ parameter Annotation?

Looks like SAL bug. The code: PAAFILEFILTER_PROTECTED_FILE curFile = NULL; try { status = GetProtectedFile(FileIdInfo, instanceContext, &curFile); if(!NT_SUCCESS(status)) { …
Brans Ds
  • 4,039
  • 35
  • 64
1
vote
0 answers

Changing Docker IP to 10.10.x.x

We are trying to use SAL on OS X. Docker and Kitematic seem to be great, but I cannot understand how to connect to SAL once it has been set up within Kitematic (Docker). The machine hosting Docker is 10.10.10.15. Docker creates a VM that runs on…
Josh
  • 175
  • 10
1
vote
1 answer

Can't understand VS2015 Analyzer report

The analyzer reports that a certain parameter is not initialized. I fail to understand why. The code: LPTSTR buffer = NULL; DWORD reqSize = 16000; DWORD dataType; LPTSTR * array; DWORD szChars; BOOL bRegProp; // Allocate buffer according to…
Shaul
  • 437
  • 5
  • 17
1
vote
1 answer

Gitfs as backend for salt-stack not working

I am using 2015.8.1 salt-master version and i want to use gitfs as backend but its not working for me. Please check the below config for the same. fileserver_backend: - git gitfs_provider: pygit2 gitfs_user: salt-stack gitfs_password:…
AniketGole
  • 889
  • 2
  • 11
  • 22
1
vote
1 answer

Is it safe to remove SAL annotations from Code?

I am porting some code from Visual Studio to Mingw gcc. I noticed that in that code a lot of annotations such as __field_ecount_opt AM_NOVTABLE _out_bcount_part_opt(x,y) are being used. I came across this thread which talks about SAL…
MistyD
  • 16,373
  • 40
  • 138
  • 240
1
vote
1 answer

Can I remove NULL and bounds checks if I use SAL?

How much can I rely on SAL? Do I need to do NSTATUS my_func(_In_ int *p) { if (NULL == p) { return STATUS_INVALID_PARAMETER; } *p = 1; return STATUS_SUCCESS; } or can I just do NTSTATUS my_func(_In_ int *p) { *p = 1; …
Thomas
  • 13
  • 2
1
vote
1 answer

Understanding __deref_out

I am new to Windows programming and I can't seem to find any resources on understanding what this SAL annotation means. I'm basically trying to look for examples so I know exactly what this means both for the caller and the callee. The MSDN article…
Bugaboo
  • 973
  • 1
  • 17
  • 36
1
vote
2 answers

Expand _In_ to const

Except for the fact, that it would probably confuse every windows c++ developer out there, wouldn't it be prudent to expand _In_ to a mandatory const (if not already present) to ensure const correctness? So int DoSomething( _In_ int *…
MrPaulch
  • 1,423
  • 17
  • 21
1
vote
1 answer

How Microsoft SAL can prevent off-by-one error

Here's an example given on MSDN (http://msdn.microsoft.com/en-us/library/hh916383.aspx) that tried to explain SAL annotation could help find a common off-by-one error. wchar_t * wmemcpy( _Out_writes_all_(count) wchar_t *dest, _In_reads_(count)…
Allan Jiang
  • 11,063
  • 27
  • 104
  • 165
0
votes
0 answers

Truncate and Load table while application is running

We have Java and reactJs based application with SQL database. We have requirement to periodically reload ( truncate and load) tables from external system while application is running. Thinking of cases where reload is in progress and application is…
Atul
  • 1
0
votes
0 answers

SAL annotation for output parameter that receives number of elements written to buffer

With a called function MyFn that allocates memory: Error MyFn(_Outptr_result_maybenull_ OBJ** const objs, _Out_ unsigned int* const numObjs) { ... } int main(void) { OBJ* objs = NULL; unsigned int numObjs = 0; MyFn(&objs,…
wulfgarpro
  • 6,666
  • 12
  • 69
  • 110
0
votes
0 answers

WinMain taken from docs can't be compiled

I have the following declaration of WinMain. int CALLBACK WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) This compiles, however it generates the following warning. Warning C28251 Inconsistent…
sanitizedUser
  • 1,723
  • 3
  • 18
  • 33
0
votes
2 answers

How do I annotate a C or C++ function using SAL to specify that it returns true/false if a parameter is non-NULL/NULL

When compiling with Microsoft's /analyze static analysis command line option for cl.exe, I get the warning warning C6011: Dereferencing NULL pointer 'foo' on a code path that calls a trivial function that guarantees that foo is not NULL where the…
Johann Gerell
  • 24,991
  • 10
  • 72
  • 122
0
votes
0 answers

C++ SAL.h errors in MSVC standard library

MSVC and Clang-CL both report errors in the standard Visual C++ headers. This must be a configuration error, as the standard headers are valid by default. Errors shown (Non declared identifier, redifinition): C:\Program Files\Microsoft Visual…
0
votes
1 answer

Can Sal annotate that parameter members may be mutated?

I am writing a reference-counted linked list of characters data structure in C for practice. I want to try using Sal in it to annotate function parameters for this practice. I have an input paremeter(named This), which I want to annotate to make it…
Dmytro
  • 5,068
  • 4
  • 39
  • 50