mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 17:18:55 +00:00
bfd/cache: change type used to track cached BFDs from int to unsigned
Within bfd/cache.c change the type for max_open_files and open_files variables from int to unsigned. As a consequence of this, the return type for bfd_cache_max_open() is also changed from int to unsigned. Within bfd_cache_max_open I've left the local 'max' variable as an int, this should ensure that if the sysconf call fails, and returns -1, then the computed max value will be less than 10, which means max_open_files will be set to 10. If 'max' was changed to unsigned then, should the sysconf call fail, we'd end up with max becoming a very large positive number ... which is clearly not what we want. And, while I was auditing how open_files is used, I added an assert within bfd_cache_delete to ensure that we don't try to reduce open_files below zero. There should be no user visible change with this commit.
This commit is contained in:
@@ -67,11 +67,11 @@ enum cache_flag {
|
||||
/* The maximum number of files which the cache will keep open at
|
||||
one time. When needed call bfd_cache_max_open to initialize. */
|
||||
|
||||
static int max_open_files = 0;
|
||||
static unsigned max_open_files = 0;
|
||||
|
||||
/* Set max_open_files, if not already set, to 12.5% of the allowed open
|
||||
file descriptors, but at least 10, and return the value. */
|
||||
static int
|
||||
static unsigned
|
||||
bfd_cache_max_open (void)
|
||||
{
|
||||
if (max_open_files == 0)
|
||||
@@ -115,7 +115,7 @@ bfd_cache_max_open (void)
|
||||
|
||||
/* The number of BFD files we have open. */
|
||||
|
||||
static int open_files;
|
||||
static unsigned open_files;
|
||||
|
||||
/* Zero, or a pointer to the topmost BFD on the chain. This is
|
||||
used by the <<bfd_cache_lookup>> macro in @file{libbfd.h} to
|
||||
@@ -176,6 +176,7 @@ bfd_cache_delete (bfd *abfd)
|
||||
snip (abfd);
|
||||
|
||||
abfd->iostream = NULL;
|
||||
BFD_ASSERT (open_files > 0);
|
||||
--open_files;
|
||||
abfd->flags |= BFD_CLOSED_BY_CACHE;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user