Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch - sort of] for 6.3 "int err;" not initialized in symfile.c/"load_section_callback (...)"
@ 2004-11-18 21:32 Paul Schlie
  2004-11-18 21:38 ` Theodore A. Roth
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Schlie @ 2004-11-18 21:32 UTC (permalink / raw)
  To: gdb-patches

Hi, sorry, not exactly a patch, but it might help someone keep their hair
a little longer...

In symfile.c within "load_section_callback (...)", "int err;" is not
initialized and may not be set by "target_write_memory_partial (...)",
so therefore may appear to fail, although all is well; which was a minor
pain discovering. (causing an apparent failure when loading remote memory)

symfile.c:

...

/* Callback service function for generic_load (bfd_map_over_sections).  */

static void
load_section_callback (bfd *abfd, asection *asec, void *data)
{
  struct load_section_data *args = data;

  if (bfd_get_section_flags (abfd, asec) & SEC_LOAD)
    {
      bfd_size_type size = bfd_get_section_size (asec);
      if (size > 0)
    {
      char *buffer;
      struct cleanup *old_chain;
      CORE_ADDR lma = bfd_section_lma (abfd, asec) + args->load_offset;
      bfd_size_type block_size;
-     int err;
+     int err = 0;
      const char *sect_name = bfd_get_section_name (abfd, asec);
      bfd_size_type sent;

      if (download_write_size > 0 && size > download_write_size)
        block_size = download_write_size;
      else
        block_size = size;

      buffer = xmalloc (size);
      old_chain = make_cleanup (xfree, buffer);

      /* Is this really necessary?  I guess it gives the user something
         to look at during a long download.  */
      ui_out_message (uiout, 0, "Loading section %s, size 0x%s lma 0x%s\n",
              sect_name, paddr_nz (size), paddr_nz (lma));

      bfd_get_section_contents (abfd, asec, buffer, 0, size);

      sent = 0;
      do
        {
          int len;
          bfd_size_type this_transfer = size - sent;

          if (this_transfer >= block_size)
        this_transfer = block_size;
          len = target_write_memory_partial (lma, buffer,
                         this_transfer, &err);
          if (err)
        break;
...

---



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

* Re: [patch - sort of] for 6.3 "int err;" not initialized in symfile.c/"load_section_callback (...)"
  2004-11-18 21:32 [patch - sort of] for 6.3 "int err;" not initialized in symfile.c/"load_section_callback (...)" Paul Schlie
@ 2004-11-18 21:38 ` Theodore A. Roth
  2004-11-18 21:46   ` Paul Schlie
  2004-11-18 22:00   ` Paul Schlie
  0 siblings, 2 replies; 4+ messages in thread
From: Theodore A. Roth @ 2004-11-18 21:38 UTC (permalink / raw)
  To: Paul Schlie; +Cc: gdb-patches

On Thu, 18 Nov 2004, Paul Schlie wrote:

> Hi, sorry, not exactly a patch, but it might help someone keep their hair
> a little longer...
>
> In symfile.c within "load_section_callback (...)", "int err;" is not
> initialized and may not be set by "target_write_memory_partial (...)",
> so therefore may appear to fail, although all is well; which was a minor
> pain discovering. (causing an apparent failure when loading remote memory)

I already brought this up a while back. Here's a link to the thread:

  http://sources.redhat.com/ml/gdb-patches/2004-10/msg00324.html


---
Ted Roth
PGP Key ID: 0x18F846E9
Jabber ID: troth@jabber.org


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

* Re: [patch - sort of] for 6.3 "int err;" not initialized in symfile.c/"load_section_callback (...)"
  2004-11-18 21:38 ` Theodore A. Roth
@ 2004-11-18 21:46   ` Paul Schlie
  2004-11-18 22:00   ` Paul Schlie
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Schlie @ 2004-11-18 21:46 UTC (permalink / raw)
  To: Theodore A. Roth; +Cc: gdb-patches

Thanks, sorry (apparently I should scan the list a little more diligently)

-paul-

> From: "Theodore A. Roth" <troth@openavr.org>
> Date: Thu, 18 Nov 2004 13:38:50 -0800 (PST)
> To: Paul Schlie <schlie@comcast.net>
> Cc: <gdb-patches@sources.redhat.com>
> Subject: Re: [patch - sort of] for 6.3 "int err;" not initialized in
> symfile.c/"load_section_callback (...)"
> 
> On Thu, 18 Nov 2004, Paul Schlie wrote:
> 
>> Hi, sorry, not exactly a patch, but it might help someone keep their hair
>> a little longer...
>> 
>> In symfile.c within "load_section_callback (...)", "int err;" is not
>> initialized and may not be set by "target_write_memory_partial (...)",
>> so therefore may appear to fail, although all is well; which was a minor
>> pain discovering. (causing an apparent failure when loading remote memory)
> 
> I already brought this up a while back. Here's a link to the thread:
> 
>   http://sources.redhat.com/ml/gdb-patches/2004-10/msg00324.html
> ---
> Ted Roth
> PGP Key ID: 0x18F846E9
> Jabber ID: troth@jabber.org



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

* Re: [patch - sort of] for 6.3 "int err;" not initialized in symfile.c/"load_section_callback (...)"
  2004-11-18 21:38 ` Theodore A. Roth
  2004-11-18 21:46   ` Paul Schlie
@ 2004-11-18 22:00   ` Paul Schlie
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Schlie @ 2004-11-18 22:00 UTC (permalink / raw)
  To: Theodore A. Roth; +Cc: gdb-patches

But as a minor follow up to your earlier note; I suspect "err" is best
initialized here, as it seems prudent to assume that called functions
may only signal errors; not necessary assert the absents of one.

Just a thought, -paul-

> From: "Theodore A. Roth" <troth@openavr.org>
> 
> On Thu, 18 Nov 2004, Paul Schlie wrote:
> 
>> Hi, sorry, not exactly a patch, but it might help someone keep their hair
>> a little longer...
>> 
>> In symfile.c within "load_section_callback (...)", "int err;" is not
>> initialized and may not be set by "target_write_memory_partial (...)",
>> so therefore may appear to fail, although all is well; which was a minor
>> pain discovering. (causing an apparent failure when loading remote memory)
> 
> I already brought this up a while back. Here's a link to the thread:
> 
>   http://sources.redhat.com/ml/gdb-patches/2004-10/msg00324.html
> 
> ---
> Ted Roth
> PGP Key ID: 0x18F846E9
> Jabber ID: troth@jabber.org



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

end of thread, other threads:[~2004-11-18 22:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-18 21:32 [patch - sort of] for 6.3 "int err;" not initialized in symfile.c/"load_section_callback (...)" Paul Schlie
2004-11-18 21:38 ` Theodore A. Roth
2004-11-18 21:46   ` Paul Schlie
2004-11-18 22:00   ` Paul Schlie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox