WDK中提示的Warning

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

 警告实例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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值