nvtop icon indicating copy to clipboard operation
nvtop copied to clipboard

Completion of error handling

Open elfring opened this issue 7 years ago • 6 comments

Would you like to add more error handling for return values from functions like the following?

elfring avatar Oct 18 '18 11:10 elfring

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.

Syllo avatar Oct 18 '18 19:10 Syllo

I suggest to avoid ignorance of return values a bit more. Would you like to detect every error situation as early as possible?

elfring avatar Oct 18 '18 20:10 elfring

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!

Syllo avatar Oct 18 '18 20:10 Syllo

elfring avatar Oct 18 '18 20:10 elfring

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 😉

Syllo avatar Oct 18 '18 20:10 Syllo

elfring avatar Oct 19 '18 07:10 elfring