This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: PATCH: Remove unnecessary zero-initializations
- From: Felix Lee <bdgle at tigerfood dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Mon, 11 Nov 2002 02:48:33 -0800
- Subject: Re: PATCH: Remove unnecessary zero-initializations
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.
--