Here is it. KeReleaseSpinLock was added temporarily to try to get rid of
PREfast warning. Unfortunately, this does not help, and a valid sequence of 2
MS's functions causes a warning:

// !!!
713 KeReleaseSpinLock(&(Disk->SpinLock), Irql);
714 IoCompleteRequest(Irp, IO_NO_INCREMENT);

vsnap.c(714) : warning 28192: No resource of the class 'SpinLock'
can be held when this function is called. 'Disk->SpinLock' is currently held.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

Re: WDK 6001: PREfast bug by 0dbell

0dbell
Fri Mar 14 09:35:43 CDT 2008

On Mar 14, 7:58=A0am, "Maxim S. Shatskih" <ma...@storagecraft.com>
wrote:
> =A0 =A0 Here is it. KeReleaseSpinLock was added temporarily to try to get =
rid of
> PREfast warning. Unfortunately, this does not help, and a valid sequence o=
f 2
> MS's functions causes a warning:
>
> // !!!
> 713 =A0 =A0KeReleaseSpinLock(&(Disk->SpinLock), Irql);
> 714 =A0 =A0 =A0 =A0 =A0 =A0IoCompleteRequest(Irp, IO_NO_INCREMENT);
>
> =A0 =A0 =A0 =A0 =A0 =A0 vsnap.c(714) : warning 28192: No resource of the c=
lass 'SpinLock'
> can be held when this function is called. 'Disk->SpinLock' is currently he=
ld.
>

If you know that the PREfast warning is false positive, why do you add
code that actually effects execution?

I would think that using a Nonmemory Resource Annotation is
preferrable in such case. For example, can you use
__drv_releasesResource or __drv_releasesResourceGlobal here?

http://msdn2.microsoft.com/en-us/library/cc264096.aspx

Unless, of course, I misunderstood what you wrote.

Don

Re: WDK 6001: PREfast bug by Maxim

Maxim
Fri Mar 14 10:10:51 CDT 2008

>If you know that the PREfast warning is false positive, why do you add
>code that actually effects execution?

KeReleaseSpinLock marked by !!! was _surely_ never intended to be executed, I
added it _for 3 minutes_ only to test PREfast. Such a binary will never be
executed.

The actual code is:

KeAcquireSpinLock
call to my function which releases the spinlock within (and UnlockIrql is
passed via parameter), the function is properly annotated and is also used in
several other places, where all is fine
IoCompleteRequest

This offended PREfast, so I added - just to check PREfast - the
KeReleaseSpinLock call just before IoCompleteRequest. Yes, a false positive.

>__drv_releasesResource or __drv_releasesResourceGlobal here?

The "my function" mentioned above surely has __drv_releasesResource(SpinLock)
and this worked in other places it is used.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Re: WDK 6001: PREfast bug by Doron

Doron
Fri Mar 14 11:48:18 CDT 2008

annotate the function which releases the lock to indicate the lock is being
released in this subfunction and pfd should be happy

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Maxim S. Shatskih" <maxim@storagecraft.com> wrote in message
news:OFD1YWehIHA.1204@TK2MSFTNGP03.phx.gbl...
> >If you know that the PREfast warning is false positive, why do you add
>>code that actually effects execution?
>
> KeReleaseSpinLock marked by !!! was _surely_ never intended to be
> executed, I
> added it _for 3 minutes_ only to test PREfast. Such a binary will never be
> executed.
>
> The actual code is:
>
> KeAcquireSpinLock
> call to my function which releases the spinlock within (and UnlockIrql
> is
> passed via parameter), the function is properly annotated and is also used
> in
> several other places, where all is fine
> IoCompleteRequest
>
> This offended PREfast, so I added - just to check PREfast - the
> KeReleaseSpinLock call just before IoCompleteRequest. Yes, a false
> positive.
>
>>__drv_releasesResource or __drv_releasesResourceGlobal here?
>
> The "my function" mentioned above surely has
> __drv_releasesResource(SpinLock)
> and this worked in other places it is used.
>
> --
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> maxim@storagecraft.com
> http://www.storagecraft.com
>