Completion of error handling
Would you like to add more error handling for return values from functions like the following?
I will not add tests for malloc/realloc etc. If they return NULL, the program may as well crash with a segfault at this point. I do not intent to recover if this situation happens.
As for the printf in main, well I if someone requests the version/help and closes stdout before exec, they may as well enjoy the successful void output.
I suggest to avoid ignorance of return values a bit more. Would you like to detect every error situation as early as possible?
Yes I'm not saying the contrary. But, in this case, it is not like the program relies on the fact that this printf succeeded to do something more, it just calls exit!
- How do you think about to improve static source code analysis also for this software?
- Would you like to choose a more appropriate program error code?
Well, if I add appropriate error code, I shall as well return ENOMEM when (m|re)alloc fails, EBADF for the printf etc. I may add these in the near future when I flushed my TODO list a bit.
Static analysis, unit test, continuous integration etc would also be great. But again, when I find the time.
I will be more than happy to accept pull requests though 😉
- Are you interested to apply aspect-oriented software development?
- How do you think about to encapsulate error detection and corresponding exception handling as a reusable aspect in your software?