This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: PATCH: minor cleanup to dwarf2read.c
- To: Eli Zaretskii <eliz at is dot elta dot co dot il>
- Subject: Re: PATCH: minor cleanup to dwarf2read.c
- From: Jim Blandy <jimb at zwingli dot cygnus dot com>
- Date: 04 Jul 2001 10:34:06 -0500
- Cc: gdb-patches at sources dot redhat dot com
- References: <Pine.SUN.3.91.1010704120651.4589B-100000@is>
Eli Zaretskii <eliz@is.elta.co.il> writes:
>
>
> On 4 Jul 2001, Jim Blandy wrote:
>
> > If you have:
> >
> > foo_buf = malloc (sizeof (*foo_buf) * foo_length);
> >
> > for (i = 0; i < foo_length; i++)
> > ...
> >
> > you don't put any scary comments around the for statement about the
> > termination conditions, do you?
>
> I meant something like this:
>
> /* The while loop below was originally this:
>
> while ((unsigned int) (info_ptr - dwarf_info_buffer)
> ((info_ptr - dwarf_info_buffer) % 4) < dwarf_info_size)
>
> This seems to be trying to round info_ptr up to the next
> four-byte boundary, but that's not what it actually did. If we
> discover the problem the old code was really trying to address,
> we can fix it properly. */
>
Right. While I understand (and completely agree with) the principle
that explanatory comments belong in the code and not in the ChangeLog
entry, in this case, I think no comment is necessary. In fact,
something like the above would (I believe) inhibit understanding of
the code, because it suggests that a perfectly straightforward loop is
actually doing something odd and subtle.