Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 1.31 KB

c28113.md

File metadata and controls

29 lines (21 loc) · 1.31 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Warning C28113
Warning C28113
11/04/2016
C28113
C28113
c3f4f143-6985-4274-a87a-59c21a82d67a

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 won't 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 doesn't 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)