Re: Programming style...



Wan-Hi wrote:

2) error checking:
SetupDiGetClassDevs and many other functions return a specific value if they fail. so should i check for failure although such case is impossible? e.g. SetupDiGetClassDevs with GUID_DEVINTERFACE_VOLUME should never fail. i ask because useless failure checks make the code unreadable.

The error checks only make the code unreadable because MS prefers a *really* bad style. Excessive return and goto is about as bad as it can get. A clean if else style and a proper indentation solves that.
.




Relevant Pages

  • Re: Thread Pre-Emption Question . . .
    ... Not checking for failure of InitializeCriticalSection, ... not checking deallocateor failure is okay because the program will continue to run correctly although it is good practice to check this in debug builds because deallocators usually only fail because of invalid arguments. ... the correct execution of error handling logic (if the access causes unplanned exceptions before data corruption and these unplanned exceptions are caught in the same place as planned exceptions for example). ... This can, and will, corrupt real data in any number of random ways depending on the work done in the writer. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Thread Pre-Emption Question . . .
    ... Not checking for failure of InitializeCriticalSection, ... not checking deallocateor failure is okay because the program will continue to run correctly although it is good practice to check this in debug builds because deallocators usually only fail because of invalid arguments. ... correct execution of error handling logic (if the access causes unplanned exceptions before data corruption and these unplanned exceptions are caught in the same place as planned exceptions for example). ... This can, and will, corrupt real data in any number of random ways depending on the work done in the writer. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Importance of Failure
    ... Very few people really think that progress happens without failure. ... You got game. ... look at how frequently you fail! ... You have to convince the world you're right (which you ...
    (sci.math)
  • Re: Importance of Failure
    ... Very few people really think that progress happens without failure. ... You got game. ... look at how frequently you fail! ... You have to convince the world you're right (which you ...
    (sci.crypt)
  • Re: quality control
    ... Almost always, zero. ... will be, on the average, only 1 bad item in 100 samplings -- ... You expect 1 failure in 10,000. ... I'm thinking with the binary outcome of fail/not fail, ...
    (sci.stat.math)

Loading