Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "André Pönitz" <apoenitz@trolltech.com>
To: gdb@sources.redhat.com
Subject: gdb sources
Date: Fri, 12 Sep 2008 15:13:00 -0000	[thread overview]
Message-ID: <200809121713.09226.apoenitz@trolltech.com> (raw)



Hi all.

I browsed a bit through gdb sources and came across a few 
question I can not answer. Maybe some kind soul can help ;-)

(1)  There is e.g.

static void
make_command (const char *arg, int from_tty)
{
  char *p;

  if (arg == 0)
    p = "make";
  else
    {
      p = xmalloc (sizeof ("make ") + strlen (arg));
      strcpy (p, "make ");
      strcpy (p + sizeof ("make ") - 1, arg);
    }

  shell_escape (p, from_tty);
}

In one branch, p points to a literal, in the other to the heap.
shell_escape() does not seem to release any memory (would
also be wrong in the literal case...), so if the else branch is
taken it's a leak, no?

(2) Most of the "strings" in gdb are "char *", even if they are
conceptionally "const char *" (i.e. coming from literal, or not
intended to be changed). Why? In some places "const" is also
used, so the reason can't be "gdb supports compilers that
don't know about 'const'". Is it "just legacy"? If so, would patches
replacing "char *" by "const char *" if appropriate be welcome?

(3) Most of the declarations in command.h are repeated in
cli/cli-decode.h even though cli-decode.h #include's command.h.
Couldn't the duplicates just be removed?

Andre'


             reply	other threads:[~2008-09-12 15:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-12 15:13 André Pönitz [this message]
2008-09-12 15:36 ` Daniel Jacobowitz

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=200809121713.09226.apoenitz@trolltech.com \
    --to=apoenitz@trolltech.com \
    --cc=gdb@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