Re: PATCH: Remove unnecessary zero-initializations

Daniel Jacobowitz
2002-11-11T14:33:32Z

On Mon, Nov 11, 2002 at 02:48:33AM -0800, Felix Lee wrote:
> 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.

Certainly it's a style issue. However, it's an awkward style issue and
anyone implementing a target should be looking over the complete list
of methods anyway. I stand by my patch... although perhaps not as
"obvious" after two objections.

--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer