Skip to content

Latest commit

 

History

History
42 lines (34 loc) · 1.09 KB

File metadata and controls

42 lines (34 loc) · 1.09 KB
description Learn more about: C26111
title C26111
ms.date 11/04/2016
ms.topic reference
f1_keywords
C26111
helpviewer_keywords
C26111
ms.assetid 85fc740a-3bbb-41b8-a848-95e243a08da9

C26111

warning C26111: Caller failing to release lock <lock> before calling function <func>.

The annotation _Requires_lock_not_held_ imposes a precondition that the lock count for the specified lock cannot be greater than zero when the function is called. Warning C26111 is issued when a function fails to release the lock before it calls another function.

Example

The following example generates warning C26111 because the _Requires_lock_not_held_ precondition is violated by the call to DoNotLock within the locked section.

typedef struct _DATA
{
    CRITICAL_SECTION cs;
    int d;
} DATA;

_Requires_lock_not_held_(p->cs)

void DoNotLock(DATA* p)
{
    EnterCriticalSection(&p->cs);
    p->d = 0;
    LeaveCriticalSection(&p->cs);
}

void LockedFunction(DATA* p)
{
    EnterCriticalSection(&p->cs);
    DoNotLock(p); // Warning C26111
    LeaveCriticalSection(&p->cs);
}