Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Resource that should have been acquired before function exit was not acquired
A function that is intended to acquire a resource before it exits has exited without acquiring the resource. This warning indicates that the function is annotated with __drv_acquiresResource
but doesn't return having actually acquired the resource. If this function is a wrapper function, a path through the function didn't reach the wrapped function. If the failure to reach the wrapped function is because the function returned an error and didn't actually acquire the resource, you might need to use a conditional annotation (__drv_when
).
If this function actually implements the acquisition of the resource, it might not be possible for PFD to detect that the resource is acquired. In that case, use a #pragma
warning to suppress the error. You can probably place the #pragma
on the line preceding the {
that begins the function body. The calling functions still need the annotation, but the Code Analysis tool won't be able to detect that the resource was acquired.
Example
__drv_acquireResourceGlobal(HWLock, lockid)
void GetHardwareLock(lockid)
#pragma warning (suppress: 28104)
{
// code to implement a hardware lock (which the Code Analysis tool can't recognize)
}