]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
bfd/cache: change type used to track cached BFDs from int to unsigned
authorAndrew Burgess <aburgess@redhat.com>
Wed, 11 Oct 2023 13:39:37 +0000 (14:39 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Thu, 12 Oct 2023 12:58:19 +0000 (13:58 +0100)
commit241f29fba6ab4c584eeb4e7f53302aa92d2c11f4
treefab24539e0523b0279ed3c056d432bfcc0e5a402
parent4b41a55fe53ce2da4823ffa3a5b94bd09bf2ab0d
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.
bfd/cache.c