osiewicz / Statula

Unix command line tool for statistics.
MIT License
7 stars 10 forks source link

added a few checks for null pointers #16

Open rugglcon opened 6 years ago

rugglcon commented 6 years ago

Wherever there was a case of a null pointer, I just had it return NULL as that's what seemed to be the style you have in your functions, I just stuck to that. Let me know if there's any problems. Takes care of #3

osiewicz commented 6 years ago

Hey, Thanks for commiting! Actually, return values like 1 or 0 are passe - they don't tell the story about the error that happened. Also, I tend to check for null pointers and just return from there - as in,

if(settings)

increases your nesting depth by one, and that's not neccessarily good - I tend to just handle errors up front like so:

if(settings == NULL)

since it seems more explicit - you handle errors directly after action (and in case of the former usage, you won't see any error handling until the appropiate else - which might happen in 1000 lines (although that would be a sign of code smell). Anyways, some of your proposed changes might make their way into main client.
Thank you!