This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch/gas]: simplify frag_grow
On Wed, Jul 06, 2011 at 09:00:29AM +0200, Tristan Gingold wrote:
> + if (newc <= 0)
> + as_fatal (_("can't extend frag to %u chars"), nchars);
Watch out for proliferation of messages. There isn't any reason for a
difference between this error and the later one. (In fact this
message isn't correct since we are extending the frag *by* nchars, not
to a total size of nchars.)
> + /* Force to allocate at least NEWC bytes. */
> + oldc = obstack_chunk_size (&frchain_now->frch_obstack);
> + obstack_chunk_size (&frchain_now->frch_obstack) = newc;
> +
> + /* Do the real work: create a new frag. */
> + frag_new (0);
> +
> + /* Restore the old chunk size. */
> + obstack_chunk_size (&frchain_now->frch_obstack) = oldc;
An alternative to fixing the error message would be to wrap the above
all in "if (newc > 0){}" and dispense with the first as_fatal call.
Your choice. Either way is OK to commit.
> + /* Make it obvious that we succeed. */
> + if (obstack_room (&frchain_now->frch_obstack) < nchars)
> + as_fatal (_("can't extend frag %u chars"), nchars);
> }
> - if (obstack_room (&frchain_now->frch_obstack) < nchars)
> - as_fatal (_("can't extend frag %u chars"), nchars);
> }
>
>
> /* Call this to close off a completed frag, and start up a new (empty)
--
Alan Modra
Australia Development Lab, IBM