[ofw] Prefast patch

James Yang jyang at xsigo.com
Fri Apr 18 13:54:39 PDT 2008


This patch is a quick workaround for Prefast. I'm not sure how big
effort/side effect will be by using native OS objects. Maybe original
author or who's been working on it for a long time can comment on this.

 

Thanks,

James

 

 

________________________________

From: Sean Hefty [mailto:sean.hefty at intel.com] 
Sent: Friday, April 18, 2008 12:53 PM
To: James Yang; ofw at lists.openfabrics.org
Subject: RE: [ofw] Prefast patch

 

Can we eliminate the warnings by just removing these abstractions and
using the native OS objects in the code?

 

 

I've made some modifications for the kernel mode driver to eliminate
Prefast errors. Can someone help to review the patch and check them in
if they're OK?

 

Patch file is also attached.

 

Thanks,

James

 

 

Index: inc/iba/ib_types.h

===================================================================

--- inc/iba/ib_types.h       (revision 1060)

+++ inc/iba/ib_types.h    (working copy)

@@ -221,7 +221,7 @@

 *

 * SOURCE

 */

-#define IB_DEFAULT_SUBNET_PREFIX
(CL_HTON64(0xFE80000000000000ULL))

+#define IB_DEFAULT_SUBNET_PREFIX
(CL_HTON64(CL_CONST64(0xFE80000000000000)))

 /**********/

 

 /****d* IBA Base: Constants/IB_NODE_NUM_PORTS_MAX

@@ -2224,7 +2224,7 @@

            IN                     const    ib_gid_t* const
p_gid )

 {

            return( ( ib_gid_get_subnet_prefix( p_gid ) &

-                       CL_HTON64( 0xFFFFFFFFFFFF0000ULL ) ) ==
CL_HTON64( 0xFEC0000000000000ULL ) );

+                      CL_HTON64( CL_CONST64( 0xFFFFFFFFFFFF0000 ) ) )
== CL_HTON64( CL_CONST64( 0xFEC0000000000000 ) ) );

 }

 /*

 * PARAMETERS

Index: inc/kernel/complib/cl_mutex_osd.h

===================================================================

--- inc/kernel/complib/cl_mutex_osd.h      (revision 1060)

+++ inc/kernel/complib/cl_mutex_osd.h   (working copy)

@@ -86,6 +86,10 @@

            IN         cl_mutex_t* const          p_mutex )

 {

            CL_ASSERT( KeGetCurrentIrql() < DISPATCH_LEVEL );

+          // Supressing Prefast Warning details are:

+          //          warning 8103 : Leaking the resource stored in
'FastMutex:p_mutex'

+          //          Path includes 3 statements on the following
lines:

+          #pragma prefast(suppress:8103, "Suprressing next line for
Prefast warning for reason mentioned above in comments")

            ExAcquireFastMutex( p_mutex );

 }

 

@@ -95,6 +99,10 @@

            IN         cl_mutex_t* const          p_mutex )

 {

            CL_ASSERT( KeGetCurrentIrql() == APC_LEVEL );

+          // Supressing Prefast Warning details are:

+          //          warning 8107 : The resource 'FastMutex:p_mutex'
must be held when calling this function..

+          //          Path includes 2 statements on the following
lines:

+          #pragma prefast(suppress:8107, "Suprressing next line for
Prefast warning for reason mentioned above in comments")

            ExReleaseFastMutex( p_mutex );

 }

 

Index: inc/kernel/complib/cl_spinlock_osd.h

===================================================================

--- inc/kernel/complib/cl_spinlock_osd.h   (revision 1060)

+++ inc/kernel/complib/cl_spinlock_osd.h            (working copy)

@@ -92,11 +92,21 @@

            CL_ASSERT( p_spinlock );

 

            if (irql == DISPATCH_LEVEL) {

+                      // Supressing Prefast Warning details are:

+                      //          warning 8103 : Leaking the resource
stored in 'SpinLock:p_spinlock->lock'.

+                      //          Path includes 7 statements on the
following lines:

+                      #pragma prefast(suppress:8103, "Suprressing next
line for Prefast warning for reason mentioned above in comments")

                        KeAcquireSpinLockAtDpcLevel( &p_spinlock->lock
);

                        p_spinlock->irql = irql;

            }

            else

+          {

+                      // Supressing Prefast Warning details are:

+                      //          warning 8103 : Leaking the resource
stored in 'SpinLock:p_spinlock->lock'.

+                      //          Path includes 7 statements on the
following lines:

+                      #pragma prefast(suppress:8103, "Suprressing next
line for Prefast warning for reason mentioned above in comments")

                        KeAcquireSpinLock( &p_spinlock->lock,
&p_spinlock->irql );

+          }

 }

 

 

@@ -107,9 +117,21 @@

            CL_ASSERT( p_spinlock );

 

            if (p_spinlock->irql == DISPATCH_LEVEL)

+          {

+                      // Supressing Prefast Warning details are:

+                      //          warning 8107 : The resource
'SpinLock:p_spinlock->lock' must be held when calling this function..

+                      //          Path includes 7 statements on the
following lines:

+                      #pragma prefast(suppress:8107, "Suprressing next
line for Prefast warning for reason mentioned above in comments")

                        KeReleaseSpinLockFromDpcLevel( &p_spinlock->lock
);

+          }

            else

+          {

+                      // Supressing Prefast Warning details are:

+                      //          warning 8107 : The resource
'SpinLock:p_spinlock->lock' must be held when calling this function..

+                      //          Path includes 7 statements on the
following lines:

+                      #pragma prefast(suppress:8107, "Suprressing next
line for Prefast warning for reason mentioned above in comments")

                        KeReleaseSpinLock( &p_spinlock->lock,
p_spinlock->irql );

+          }

 }

 

 

Index: inc/kernel/complib/cl_waitobj_osd.h

===================================================================

--- inc/kernel/complib/cl_waitobj_osd.h     (revision 1060)

+++ inc/kernel/complib/cl_waitobj_osd.h  (working copy)

@@ -58,8 +58,11 @@

             * Assumption that if the call fails, the h_kevent parameter
is unchanged,

             * or set to NULL.

             */

-           ObReferenceObjectByHandle( h_user_wait_obj,
STANDARD_RIGHTS_ALL,

-                       *ExEventObjectType, UserMode, (PVOID*)&h_kevent,
NULL );

+          // Supressing Prefast Warning details are:

+          //          warning 8126 : The AccessMode parameter to
ObReferenceObject* should be IRP->RequestorMode..

+          //          Path includes 7 statements on the following
lines:

+          #pragma prefast(suppress:8126, "Suprressing next line for
Prefast warning for reason mentioned above in comments")

+          ObReferenceObjectByHandle( h_user_wait_obj,
STANDARD_RIGHTS_ALL, *ExEventObjectType, UserMode, (PVOID*)&h_kevent,
NULL );

 

            return h_kevent;

 }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080418/81560aaf/attachment.html>


More information about the ofw mailing list