if (!d && create)
{
/* No chunk for this address, so make one up. */
- d = (struct data_struct *)
- bfd_zalloc (abfd, (bfd_size_type) sizeof (struct data_struct));
-
+ d = bfd_zalloc (abfd, sizeof (struct data_struct));
if (!d)
return NULL;
return d;
}
-static void
+static bool
insert_byte (bfd *abfd, int value, bfd_vma addr)
{
if (value != 0)
{
/* Find the chunk that this byte needs and put it in. */
struct data_struct *d = find_chunk (abfd, addr, true);
+ if (!d)
+ return false;
d->chunk_data[addr & CHUNK_MASK] = value;
d->chunk_init[(addr & CHUNK_MASK) / CHUNK_SPAN] = 1;
}
+ return true;
}
/* The first pass is to find the names of all the sections, and see
while (*src && src < src_end - 1)
{
- insert_byte (abfd, HEX (src), addr);
+ if (!insert_byte (abfd, HEX (src), addr))
+ return false;
src += 2;
addr++;
}
return _bfd_no_cleanup;
}
-static void
+static bool
move_section_contents (bfd *abfd,
asection *section,
const void * locationp,
{
/* Different chunk, so move pointer. */
d = find_chunk (abfd, chunk_number, must_write);
+ if (!d)
+ return false;
prev_number = chunk_number;
}
location++;
}
+ return true;
}
static bool
tekhex_get_section_contents (bfd *abfd,
asection *section,
- void * locationp,
+ void *location,
file_ptr offset,
bfd_size_type count)
{
- if (section->flags & (SEC_LOAD | SEC_ALLOC))
- {
- move_section_contents (abfd, section, locationp, offset, count, true);
- return true;
- }
-
- return false;
+ if ((section->flags & (SEC_LOAD | SEC_ALLOC)) == 0)
+ return false;
+ return move_section_contents (abfd, section, location, offset, count, true);
}
static bool
static bool
tekhex_set_section_contents (bfd *abfd,
sec_ptr section,
- const void * locationp,
+ const void *location,
file_ptr offset,
- bfd_size_type bytes_to_do)
+ bfd_size_type count)
{
- if (section->flags & (SEC_LOAD | SEC_ALLOC))
- {
- move_section_contents (abfd, section, locationp, offset, bytes_to_do,
- false);
- return true;
- }
-
- return false;
+ if ((section->flags & (SEC_LOAD | SEC_ALLOC)) == 0)
+ return false;
+ return move_section_contents (abfd, section, location, offset, count, false);
}
static void