aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2004-05-05 15:39:11 +0000
committerNick Clifton <nickc@redhat.com>2004-05-05 15:39:11 +0000
commit06fc8a8ce6dc6e3896c672e2b809fc9a44077fed (patch)
tree6a4f69d5dd07e13a8404edbb70810bf64128140b
parent6b6e92f432c86611c81a5da6880946bad25b59dc (diff)
downloadgdb-06fc8a8ce6dc6e3896c672e2b809fc9a44077fed.zip
gdb-06fc8a8ce6dc6e3896c672e2b809fc9a44077fed.tar.gz
gdb-06fc8a8ce6dc6e3896c672e2b809fc9a44077fed.tar.bz2
PR/136 - Have bfd_cache_lookup_worker() abort rather than return an
(unchecked-for) NULL.
-rw-r--r--bfd/ChangeLog12
-rw-r--r--bfd/archive.c30
-rw-r--r--bfd/cache.c19
3 files changed, 35 insertions, 26 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 5ffb9fe..554e3b4 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,15 @@
+2004-05-05 Nick Clifton <nickc@redhat.com>
+
+ PR/136
+ * cache.c (bfd_cache_lookup_worker): Call abort() rather than
+ returning NULL as most users of this function do not check its
+ return value.
+
+2004-05-05 Nick Clifton <nickc@redhat.com>
+
+ * cache.c (bfd_cache_lookup): Improve formatting.
+ * archive.c: Fix formatting.
+
2004-05-05 Peter Barada <peter@the-baradas.com>
* bfd_archures.c(bfd_architecture): Add 521x,5249,547x,548x.
diff --git a/bfd/archive.c b/bfd/archive.c
index ba6e684..a8d53c6 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -221,7 +221,7 @@ bfd_get_next_mapent (bfd *abfd, symindex prev, carsym **entry)
return prev;
}
-/* To be called by backends only */
+/* To be called by backends only. */
bfd *
_bfd_create_empty_archive_element_shell (bfd *obfd)
@@ -261,7 +261,8 @@ _bfd_look_for_bfd_in_cache (bfd *arch_bfd, file_ptr filepos)
return NULL;
}
-/* Kind of stupid to call cons for each one, but we don't do too many */
+/* Kind of stupid to call cons for each one, but we don't do too many. */
+
bfd_boolean
_bfd_add_bfd_to_archive_cache (bfd *arch_bfd, file_ptr filepos, bfd *new_elt)
{
@@ -316,8 +317,7 @@ get_extended_arelt_filename (bfd *arch, const char *name)
Presumes the file pointer is already in the right place (ie pointing
to the ar_hdr in the file). Moves the file pointer; on success it
should be pointing to the front of the file contents; on failure it
- could have been moved arbitrarily.
-*/
+ could have been moved arbitrarily. */
void *
_bfd_generic_read_ar_hdr (bfd *abfd)
@@ -670,7 +670,7 @@ bfd_generic_archive_p (bfd *abfd)
/* The size of the string count. */
#define BSD_STRING_COUNT_SIZE 4
-/* Returns FALSE on error, TRUE otherwise */
+/* Returns FALSE on error, TRUE otherwise. */
static bfd_boolean
do_slurp_bsd_armap (bfd *abfd)
@@ -901,8 +901,8 @@ bfd_slurp_armap (bfd *abfd)
return TRUE;
}
-/* Returns FALSE on error, TRUE otherwise */
-/* flavor 2 of a bsd armap, similar to bfd_slurp_bsd_armap except the
+/* Returns FALSE on error, TRUE otherwise. */
+/* Flavor 2 of a bsd armap, similar to bfd_slurp_bsd_armap except the
header is in a slightly different order and the map name is '/'.
This flavour is used by hp300hpux. */
@@ -932,7 +932,7 @@ bfd_slurp_bsd_armap_f2 (bfd *abfd)
return FALSE;
if (!strncmp (nextname, "__.SYMDEF ", 16)
- || !strncmp (nextname, "__.SYMDEF/ ", 16)) /* old Linux archives */
+ || !strncmp (nextname, "__.SYMDEF/ ", 16)) /* Old Linux archives. */
return do_slurp_bsd_armap (abfd);
if (strncmp (nextname, "/ ", 16))
@@ -1296,7 +1296,7 @@ _bfd_construct_extended_name_table (bfd *abfd,
return TRUE;
}
-/** A couple of functions for creating ar_hdrs */
+/* A couple of functions for creating ar_hdrs. */
#ifdef HPUX_LARGE_AR_IDS
/* Function to encode large UID/GID values according to HP. */
@@ -1765,9 +1765,9 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
bfd *current;
file_ptr elt_no = 0;
struct orl *map = NULL;
- unsigned int orl_max = 1024; /* fine initial default */
+ unsigned int orl_max = 1024; /* Fine initial default. */
unsigned int orl_count = 0;
- int stridx = 0; /* string index */
+ int stridx = 0;
asymbol **syms = NULL;
long syms_max = 0;
bfd_boolean ret;
@@ -1916,7 +1916,7 @@ bsd_write_armap (bfd *arch,
unsigned int mapsize = ranlibsize + stringsize + 8;
file_ptr firstreal;
bfd *current = arch->archive_head;
- bfd *last_elt = current; /* last element arch seen */
+ bfd *last_elt = current; /* Last element arch seen. */
bfd_byte temp[4];
unsigned int count;
struct ar_hdr hdr;
@@ -1960,7 +1960,7 @@ bsd_write_armap (bfd *arch,
current = current->next;
}
while (current != map[count].u.abfd);
- } /* if new archive element */
+ }
last_elt = current;
H_PUT_32 (arch, map[count].namidx, buf);
@@ -2058,8 +2058,7 @@ _bfd_archive_bsd_update_armap_timestamp (bfd *arch)
symbol name 0
symbol name 1
- symbol name n-1
-*/
+ symbol name n-1 */
bfd_boolean
coff_write_armap (bfd *arch,
@@ -2104,7 +2103,6 @@ coff_write_armap (bfd *arch,
(((char *) (&hdr))[i]) = ' ';
/* Write the ar header for this item and the number of symbols. */
-
if (bfd_bwrite (&hdr, sizeof (struct ar_hdr), arch)
!= sizeof (struct ar_hdr))
return FALSE;
diff --git a/bfd/cache.c b/bfd/cache.c
index 0586061..58eda91 100644
--- a/bfd/cache.c
+++ b/bfd/cache.c
@@ -189,9 +189,9 @@ bfd *bfd_last_cache;
otherwise, it has to perform the complicated lookup function.
.#define bfd_cache_lookup(x) \
- . ((x)==bfd_last_cache? \
- . (FILE*) (bfd_last_cache->iostream): \
- . bfd_cache_lookup_worker(x))
+ . ((x) == bfd_last_cache ? \
+ . (FILE *) (bfd_last_cache->iostream): \
+ . bfd_cache_lookup_worker (x))
*/
@@ -438,7 +438,8 @@ DESCRIPTION
quick answer. Find a file descriptor for @var{abfd}. If
necessary, it open it. If there are already more than
<<BFD_CACHE_MAX_OPEN>> files open, it tries to close one first, to
- avoid running out of file descriptors.
+ avoid running out of file descriptors. It will abort rather than
+ returning NULL if it is unable to (re)open the @var{abfd}.
*/
FILE *
@@ -461,12 +462,10 @@ bfd_cache_lookup_worker (bfd *abfd)
}
else
{
- if (bfd_open_file (abfd) == NULL)
- return NULL;
- if (abfd->where != (unsigned long) abfd->where)
- return NULL;
- if (real_fseek ((FILE *) abfd->iostream, abfd->where, SEEK_SET) != 0)
- return NULL;
+ if (bfd_open_file (abfd) == NULL
+ || abfd->where != (unsigned long) abfd->where
+ || real_fseek ((FILE *) abfd->iostream, abfd->where, SEEK_SET) != 0)
+ abort ();
}
return (FILE *) abfd->iostream;