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
2
votes
1 answer

C6001 with overloaded assignment operator

This simplified example code raises C6001 under static analysis: struct st_facade { st_facade &operator=(const int new_value) { m_value = new_value; return *this;} private: int m_value; }; struct foo { st_facade my_int; }; void…
Tim Sparkles
  • 771
  • 6
  • 21
2
votes
0 answers

SAL annotations for returning reference counted objects

I'm trying to use SAL annotations to guard against certain possible errors when using reference counted objects. Annotations specific for this use case are not available (as far as I can tell), but using the locking annotations could work. typedef…
icebp
  • 1,608
  • 1
  • 14
  • 24
2
votes
0 answers

Add /Wall when running code analysis only?

During my regular builds, I have /W4 turned on, with a few additional warnings as well, and some that are simply disabled due to too many false positives with Visual Studio. This mostly works okay, but I'd still like, from time to time, to check on…
ChrisMM
  • 8,448
  • 13
  • 29
  • 48
2
votes
1 answer

C++ source_annotation_attribute

When browsing the source of the open source .NET Framework 4.7 I stumbled across the C++ header sal.h and found a line of code saying [source_annotation_attribute( SA( Method ) )] which seems to be similar to attributes and the AttributesUsage class…
Thomas Flinkow
  • 4,845
  • 5
  • 29
  • 65
2
votes
1 answer

Jira SAL using PluginSettings

I looked for a way to store project-specific configurations for my plugin. In the first step i only want to store a simple String like "Hello". So, what i found is SAL and the…
Don
  • 227
  • 1
  • 15
2
votes
1 answer

What does this typedef mean involving LPWSTR?

I am trying to find a substitute for LPWSTR for porting a project to gcc. typedef __nullterminated WCHAR *NWPSTR, *LPWSTR, *PWSTR; What is null terminated ? so would it be safe if I did something like this: typedef WCHAR *LPWSTR
MistyD
  • 16,373
  • 40
  • 138
  • 240
2
votes
2 answers

Output of pointer to caller SAL error

I am trying to add SALto my code... i worked according msdn and found bug in msdn examples, don't know how to deal with it. Here litle changed example "Output of pointer to caller (Example: The Outptr Annotation)" from Understanding SAL Outptr is…
Brans Ds
  • 4,039
  • 35
  • 64
1
vote
1 answer

presto sql query for getting the fill rate of the table

I want a generic query to get fill rate of all columns in table .Query should work irrespective of the column number.I have to implement this using presto sql.I have tried searching for a method but nothing seems to…
aju_dev
  • 25
  • 5
1
vote
1 answer

Microsoft source code annotation language (SAL) does not give C26100 or other warnings

I am trying to see if SAL can be used to detect concurrency bugs. I prepared a project according to Sample C++ project for code analysis and tried the sample code on Code analysis for C/C++ warnings. However, I am not getting the warnings that…
minguu42
  • 11
  • 1
1
vote
1 answer

How do I enforce SAL annotations on a typedef'd function?

Let's say I import a DLL function like so: typedef int(__stdcall *pRandomNumber)(size_t cb, unsigned char *pb); HINSTANCE hDLL = LoadLibraryW(L"foo.dll"); pRandomNumber RandomNumber = (pRandomNumber)GetProcAddress(hDLL, "RandomNumber"); Now, this…
Govind Parmar
  • 20,656
  • 7
  • 53
  • 85
1
vote
1 answer

How can i write this function using SAL annotations for C in Visual Studio?

How can i write this function using SAL annotations for C? I need to implement some functions and i dont know how to declare them. I just need 1 function as a model, so i can implement the rest. Down here is my main C file with take all the hanldes…
NullByte55
  • 11
  • 1
1
vote
0 answers

Why is SAL reporting this loop as a potential buffer overrun?

// Global: const WCHAR g_Table[] = L"AbCdEfGhIjKlMnOpQrStUvWxYzaBcDeFgHiJkLmNoPqRsTuVwXyZ2468013579"; // In function: void myFunction() { WCHAR *randomFileName = NULL; size_t cchFileName = 7 + (rand() % 7); randomFileName =…
Govind Parmar
  • 20,656
  • 7
  • 53
  • 85
1
vote
0 answers

Error C2059 while declaring macro that uses SAL to define a type (?)

I inherited some code, the code in question builds (for someone I have no access to, in a way older version of VS.) I am attempting to migrate it to VS2019. One error I keep getting is: Error C2059 syntax error: '[' At:…
ogulbuk
  • 11
  • 1
1
vote
1 answer

Configure Doxygen to ignore the Source-Code Annotation Language (SAL)

I have some classes that are documented with Doxygen. Additionally, they are annotated with Microsoft's Source-Code Annotation Language (SAL) to support static code analysis. //! The majestic class. class Foo { //! \brief do something //!…
harper
  • 13,345
  • 8
  • 56
  • 105
1
vote
0 answers

Visual Studio 2015 string.h inconsistent annotations

I am using visual studio 2015 and i've also installed ( and reinstalled ) the latest sdk. I started a new project and set the warning level, i've also set "Treat warnings as errors" and i've set to run static code analysis on build. A simple main.c…
user2997092
  • 63
  • 1
  • 12