From: Jim Blandy <jimb@zwingli.cygnus.com>
To: Eli Zaretskii <eliz@is.elta.co.il>
Cc: gdb-patches@sources.redhat.com
Subject: Re: PATCH: minor cleanup to dwarf2read.c
Date: Wed, 04 Jul 2001 01:28:00 -0000 [thread overview]
Message-ID: <npy9q5nllr.fsf@zwingli.cygnus.com> (raw)
In-Reply-To: <Pine.SUN.3.91.1010704095837.3231R-100000@is>
Eli Zaretskii <eliz@is.elta.co.il> writes:
> On Tue, 3 Jul 2001, Jim Blandy wrote:
>
> > 2001-07-03 Jim Blandy <jimb@redhat.com>
> >
> > * dwarf2read.c (dwarf2_build_psymtabs_hard): Remove extraneous
> > code in loop condition. This seemed 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.
>
> IMHO, ChangeLog is never a proper place to put such comments. Should
> the problem surface in the future, how do we expect someone to find
> this piece of info?
>
> I suggest to put this text as a comment in the source, together with a
> copy of the old code, in case someone will actually need to fix
> this.
I did hesitate to put that in the ChangeLog. I didn't because I felt
the code was pretty obvious.
There's a buffer of byte-oriented data, dwarf_info_buffer, whose
length in bytes is dwarf_info_size. We're walking through it with a
char pointer named info_ptr. Each iteration through the loop, we
advance info_ptr over some variable number of bytes. There's no way
clever tests for termination belong in the while condition, since the
things we're reading have non-trivial structure; overrun tests need to
be in the individual functions that consume data and advance info_ptr.
In other words, it was a perfectly straightforward situation marred by
obscure code. I don't think it really needs a comment at all. 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?
next prev parent reply other threads:[~2001-07-04 1:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-03 15:29 Jim Blandy
2001-07-03 23:57 ` Eli Zaretskii
2001-07-04 1:28 ` Jim Blandy [this message]
2001-07-04 2:10 ` Eli Zaretskii
2001-07-04 8:33 ` Jim Blandy
2001-07-04 9:30 ` Andrew Cagney
2001-07-04 9:11 Jim Blandy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=npy9q5nllr.fsf@zwingli.cygnus.com \
--to=jimb@zwingli.cygnus.com \
--cc=eliz@is.elta.co.il \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox