Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [commit][obv] Use TYPE_LENGTH directly where possible
Date: Wed, 26 Sep 2012 09:58:00 -0000	[thread overview]
Message-ID: <20120926152740.0900e9b7@spoyarek> (raw)
In-Reply-To: <20120926094227.GA4335@adacore.com>

On Wed, 26 Sep 2012 11:42:27 +0200, Joel wrote:
> > @@ -637,7 +637,7 @@ amd64_return_value (struct gdbarch *gdba
> >      }
> >  
> >    gdb_assert (class[1] != AMD64_MEMORY);
> > -  gdb_assert (len <= 16);
> > +  gdb_assert (TYPE_LENGTH (type) <= 16);
> >  
> >    for (i = 0; len > 0; i++, len -= 8)
> >      {
> 
> Why is the type not OK for the assert, and yet OK for the rest of
> the code? (the same question applies to other files, as well)

This is so that the assert is not subject to any truncation/overflow
resulting due to the type of LEN.  That way, I don't have to expand LEN
since I know that the value is always going to be less than 16 and if
something actually goes wrong, then the assert will definitely catch it.

> Why is it better to repeat the use of TYPE_LENGTH rather than use
> a single variable? It's definitely not obvious to me, and it seems
> even simpler to just change the type of variable "len"... This patch
> feels like a step backwards, and trying to reduce the size of a patch
> would be the wrong justification for it.
> 

It does not make any functional difference at all and the justification
is in fact that it reduces the size of the bitpos patch.  I have
committed similar changes in the past that were deemed to be OK, so I
don't see why this patch in particular should be a problem.

I have not made changes in places where more than 4-5 substitutions
were necessary and where the code started looking unwieldy as a
result.  I guess both those parameters are subjective, but I couldn't
see a coding convention that seems to have been strictly followed
throughout the code base.

Regards,
Siddhesh


  reply	other threads:[~2012-09-26  9:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-26  7:57 Siddhesh Poyarekar
2012-09-26  9:42 ` Joel Brobecker
2012-09-26  9:58   ` Siddhesh Poyarekar [this message]
2012-09-26 10:52     ` Joel Brobecker
2012-09-26 14:59       ` Pedro Alves
2012-09-26 15:09         ` Siddhesh Poyarekar
2012-09-26 15:07       ` Tom Tromey
2012-09-28  4:00       ` Mark Kettenis
2012-09-28  8:11         ` Jan Kratochvil
2012-09-27  9:59 ` Joel Brobecker
2012-09-27 10:13   ` Siddhesh Poyarekar
2012-09-27 10:19     ` Joel Brobecker
2012-09-27 10:42       ` Siddhesh Poyarekar

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=20120926152740.0900e9b7@spoyarek \
    --to=siddhesh@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /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