Skip to content

Latest commit

 

History

History
38 lines (30 loc) · 1008 Bytes

c26112.md

File metadata and controls

38 lines (30 loc) · 1008 Bytes
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Warning C26112
Warning C26112
11/04/2016
C26112
C26112
926de738-b9b0-43d7-9137-ab2daa44ad4d

Warning C26112

Caller cannot hold any lock before calling 'func'.

The annotation _Requires_no_locks_held_ imposes a precondition that the caller must not hold any lock while it calls the function. Warning C26112 is issued when a function fails to release all locks before it calls another function.

Example

The following example generates warning C26112 because the _Requires_no_locks_held_ precondition is violated by the call to NoLocksAllowed within the locked section.

typedef struct _DATA
{
    CRITICAL_SECTION cs;
} DATA;

_Requires_no_locks_held_

void NoLocksAllowed(DATA* p)
{
     // Lock sensitive operations here
}

void LocksHeldFunction(DATA* p)
{
    EnterCriticalSection(&p->cs);
    NoLocksAllowed(p); // Warning C26112
    LeaveCriticalSection(&p->cs);
}