public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* find_and_open_source bug?
@ 2011-10-29 20:47 Doug Evans
  2011-11-01 19:11 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Doug Evans @ 2011-10-29 20:47 UTC (permalink / raw)
  To: gdb

If find_and_open_source opens the file via rewrite_source_path,
should xfullname get called?
Grep for XXX below.

Seems so, otherwise the caller can't really assume what's
stored in *fullname is a "fullpath" (as defined by xfullpath).
[Maybe rewritten source paths shouldn't get passed through xfullpath
but then why does the rest of the function do that?]

[I'm trying to understand what invariants callers of find_and_open_source
can expect.]

int
find_and_open_source (const char *filename,
		      const char *dirname,
		      char **fullname)
{
  char *path = source_path;
  const char *p;
  int result;

  /* Quick way out if we already know its full name.  */

  if (*fullname)
    {
      /* The user may have requested that source paths be rewritten
         according to substitution rules he provided.  If a substitution
         rule applies to this path, then apply it.  */
      char *rewritten_fullname = rewrite_source_path (*fullname);

      if (rewritten_fullname != NULL)
        {
          xfree (*fullname);
          *fullname = rewritten_fullname;
        }

      result = open (*fullname, OPEN_MODE);
      if (result >= 0)
        XXX shouldn't we pass *fullname through xfullpath here?
	return result;
      /* Didn't work -- free old one, try again.  */
      xfree (*fullname);
      *fullname = NULL;
    }
[...]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-01 19:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-29 20:47 find_and_open_source bug? Doug Evans
2011-11-01 19:11 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).