Partager via


C28113

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

warning C28113: Accessing a local variable via an Interlocked function

The driver is using an Interlocked executive support routine, such as InterlockedDecrement, to access a local variable.

Although drivers are permitted to pass the address of a local variable to another function, and then use an interlocked function to operate on that variable, it's important to verify that the stack will not be swapped out to disk unexpectedly and that the variable has the correct life time across all threads that might use it.

Example

Typically, the return value of an Interlocked executive support routine is used in subsequent computations, instead of the input arguments. Also, the Interlocked routines only protect the first (leftmost) argument. Using an Interlocked routine in the following way does not protect the value of global and often serves no purpose.

InterlockedExchange(&local, global)  

The following form has the same effect on the data and safely accesses the global variable.

local = InterllockedExchange(&global, global)