Check return codes everywhere
Brought to you by:
dsandersorem,
jcalcote
Some checks for return codes are missing.
Examples:
Would you like to add more error handling for return values at the following places?
- fprintf (function "log_time")
http://openxdas.svn.sourceforge.net/viewvc/openxdas/trunk/openxdas/xdasd/src/xdasd_log.c?revision=190&view=markup
- pthread_join (function "thread_wait")
pthread_mutex_lock (function "sem_signal")
http://openxdas.svn.sourceforge.net/viewvc/openxdas/trunk/openxdas/xdasd/src/xdasd_thread.c?revision=180&view=markup
Logged In: NO
Please indicate rationale for change request like this. pthread_join does return an error code, but it doesn't do me much good in the grander scheme of things. I can't really use it effectively in higher level code except to note in the log file that I couldn't really "join the other thread". Rather than return an error code in this situation, I find it makes a simpler interface if I just return a standard return code (zero in this case), if pthread_join doesn't work.
I'm not arguing with you - just giving you my thoughts. If you have a good reason, I'd be happy to consider a change.
As far as the fprintf is concerned - do you really check the return code of fprintf in your code?
Logged In: YES
user_id=180450
Originator: NO
Previous comment made by myself. Sorry for not logging in first.
Logged In: YES
user_id=572001
Originator: YES
1. You do not need to make assumptions about error situations. Please check all return values.
Otherwise, it might not be noticed if anything unexpected went wrong.
2. How do you think about to call "exit(errno)" or "abort()"?
3. Would you like to use exception handling?
http://cexcept.sourceforge.net/
http://dietmar-kuehl.de/mirror/c++-faq/exceptions.html#faq-17.1