CloseHandle():Return value check require
I am using CloseHandle()
to close the handle to a thread.
This is done towards the end of the program and 开发者_如何转开发hence cleanup operation should be irrespective of the return value of the CloseHandle
pc-lint reports error that, ignoring return value of function.
Kindly let me know if there will be any issue if ignoring the return value.
Easy Answer: I don't think I've ever seen any code anywhere that checks the return value of a CloseHandle, nor has a CloseHandle not working ever been the cause of any bug I've ever seen in 15+ years of programming on Windows (YMMV).
Real Answer: Of course you should check the error return (of all methods that could return failure, all the time), assuming your application has a consistent error handling framework already in place you would simply work with that. Failing to consistently check return values and assuming success is a recipe for bigger, often harder to understand, failures later in the code.
That said: Would I worry about CloseHandle failing during the application shutdown? Probably not. But thats only my 2 cents.
精彩评论