Re: PATCH: Remove unnecessary zero-initializations

Felix Lee
2002-11-11T10:48:40Z

Daniel Jacobowitz <drow@mvista.com>:
> Currently, thirteen files which provide a target_ops explicitly initialize
> members they don't support to NULL.

this is a style and readability issue. if every set of
initializations is complete and mentions all members, even
when "unnecessary", then it's easier to quickly check that
an implementation correctly matches the specification. a
statement like
foo.bar = 0;
indicates that the programmer was aware that foo.bar exists,
thought about it, and decided that 0 is a correct value.

if the statement is missing, you have to spend time deciding
if the programmer omitted it accidentally or not.

a different technique is to put a note in a comment instead
of as a statement:
// foo.bar can be 0
but this is a pointless micro-optimization, it's an
optimization a compiler could be taught how to do, and you
lose the opportunity to have an automated tool check for you
that initializations are complete.
--