Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
A situation
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Nick, post: 1699384"] A well thought out exception to the rule. If it fails early, return early, and it is obvious why you have returned the value you did. In device drivers I have seen and written, the common practice was to put all of these things up front, e.g. if(some_condition) return ENODEV; if(some_other_condition /*based on the input parameters*/) return EFAULT; etc. Then, finally, the "meat" when all error checks on the input had been performed. I find this more readable than: retval = 0; if(some_condition) retval = ENODEV; if(some_other_condition) retval = EFAULT; .... if (retval == 0) { /*meat*/ retval = whatever; } return retval; but your preferences may vary. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
A situation
Top