WDK中提示的Warning

以前从来没有注意WDK在编译之后,虽然没有在build的时候直接提示警告信息,但是会在ORCA的一个界面中提示程序中存在的一些Warnning,比如:
WDK中提示的Warning_第1张图片
 警告实例1:

warning 28197: Possibly leaking memory 'pMacInfo':

如果你上网查找这个错误:http://msdn.microsoft.com/en-us/library/aa468922.aspx

那你就会发现,在程序中忘记了释放已经分配的内存:

        pMacInfo =  (PDOT11_MAC_INFO)NdisAllocateMemoryWithTagPriority(pFilter->FilterHandle, sizeof(DOT11_MAC_INFO), FILTER_ALLOC_TAG, LowPoolPriority);
		NdisZeroMemory(pMacInfo,sizeof(DOT11_MAC_INFO));
	    DEBUGP(DL_TEST,("sizeof DOT11_MAC_INFO is%u!\n",sizeof(DOT11_MAC_INFO)));
		Status = filterDoInternalRequest(pFilter,
	                                  NdisRequestMethod,
									  Oid,
									  pMacInfo,
									  sizeof(DOT11_MAC_INFO),
									  sizeof(DOT11_MAC_INFO),
									  MethodId,
									  &BytesProcessed); 
....(略)
		 } 
       NdisFreeMemory(pMacInfo,0,0);

 

如果你没有NdisFreeMemory()这条语句,他就会提示说可能存在内存泄露。

 

 警告实例2:

 

133            DriverObject->DriverUnload = FilterUnload;
 
       

filter.c(133) : warning 28175: The 'DriverUnload' member of _DRIVER_OBJECT should not be accessed by a driver: Access to this member may be permitted for certain classes of drivers. See the documentation for this warning for more information.
Found in function 'DriverEntry'

这里说成员DriverUnload不应该被驱动访问~ 没有找到原因,暂且记录!

 

 警告实例3:

28193 - <Variable> holds a value that must be examined

 NdisQueryMdl(
            pMdl,
            (PVOID *)&pCopyData,
            &BufferLength,
            NormalPagePriority);
FILTER_ASSERT(pCopyData != NULL);// Exception will rise if no this statment

 

The driver should test the value of the specified variable, which was supplied by a function, but the driver is either not using the value or is overwriting the value without examining it.

你可能感兴趣的:(C++,c,Microsoft,C#,Access)