Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: brobecker@adacore.com, siddhesh@redhat.com, gdb-patches@sourceware.org
Subject: Re: [commit][obv] Use TYPE_LENGTH directly where possible
Date: Fri, 28 Sep 2012 08:11:00 -0000	[thread overview]
Message-ID: <20120928081056.GA22720@host2.jankratochvil.net> (raw)
In-Reply-To: <201209280400.q8S40iKO021106@glazunov.sibelius.xs4all.nl>

On Fri, 28 Sep 2012 06:00:44 +0200, Mark Kettenis wrote:
> > Date: Wed, 26 Sep 2012 12:52:06 +0200
> > From: Joel Brobecker <brobecker@adacore.com>
> > I agree it's subjective. Just FYI, my tolerance starts at 2.  If I need
> > to repeat an expression, I often start thinking about factorizing into
> > constants, functions, etc (duplication is not the only part of the
> > decision process, so I don't necessarily do it).
> 
> I agree with Joel.  Actually my tolerance starts at 1, if it avoids
> having lines that are too long or if it reduces the number of nested
> parentheses to a more manageable level.

In my opinion it cannot be so generalized.  In a larger code using 'len'
variable may be for example less clear because its value may have become stale
after its original 'type' has been updated in the meantime etc.

Anyway thanks for the opinions, personally I do not have opinion on these
differences.

Although I found fine this kind of change (which I pre-approved to Siddhesh as
[obv] according to my opinion):
   ULONGEST val;
-  int len = TYPE_LENGTH (type);

-  if (len <= 4)
+  if (TYPE_LENGTH (type) <= 4)
     {
{ possibly more uses of 'len' }

But I no longer find fine this kind of change contained in this patch:
   int len = TYPE_LENGTH (type);
   ULONGEST c, addr;

-  switch (len)
+  switch (TYPE_LENGTH (type))
     {

because one should not check-in patch which brings the codebase to a state
which is not acceptable as the final solution, which this second case
acceptable is not.


Thanks,
Jan


  reply	other threads:[~2012-09-28  8:11 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
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 [this message]
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=20120928081056.GA22720@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    --cc=siddhesh@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