Re: Little code cleanup
Paul Walker (2008/03/03 15:32 +0000):
> But you can say that about any item of code. Any part of the tree might
> change at some point to render an assumption invalid. In the same function,
> there are strings helpstr and buf which are used without checking - by your
> logic, they should be checked on each use just in case someone happens to
> change the code structure.
>
> At least for myself, I'd prefer a warning free build to warnings which come
> out just because someone might potentially, hypothetically change a piece of
> code at some random time in the indefinite future. I think a warning-free
> build gives us much more in terms of usefulness.
>
> Defensive programming is all very well, but you can definitely take it too
> far. :-)
Needless to say, I totally agree with Paul.
I'd like to add two things.
1. I'm also _very_ interested in a warning-free compilation, because if
the habit is to have no warnings at all, then each single warning which
appears in the future is much more easy to notice. If it appears in a
long list of warnings, chances are high that I (and perhaps others)
won't notice it.
2. It is true that testing pointers may avoid segfaults, but they don't
avoid problems. What I mean is that, if a pointer becomes NULL whereas
it should not, having a segfault makes it much easier to debug the
problem, IMHO, than having a leading to some fallback behaviour.
Sébastien.