From: Alan Modra Date: Wed, 9 Jul 2014 10:34:40 +0000 (+0930) Subject: Account for trailing bytes read from bfd_bread X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=87f14779da25380b2e1ee67edcf984f0f8c922c4;p=binutils-gdb.git Account for trailing bytes read from bfd_bread * cache.c (cache_bread_1): Don't return -1 when fread returns a positive value. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8c922aa7a87..96f85f7013c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2014-07-15 Alan Modra + + * cache.c (cache_bread_1): Don't return -1 when fread returns + a positive value. + 2014-07-15 Alan Modra * elflink.c (elf_merge_st_other): Update comments. Simplify diff --git a/bfd/cache.c b/bfd/cache.c index 27fe70a84c6..ffda00452de 100644 --- a/bfd/cache.c +++ b/bfd/cache.c @@ -310,7 +310,7 @@ cache_bread_1 (struct bfd *abfd, void *buf, file_ptr nbytes) if (nread == (file_ptr)-1) { bfd_set_error (bfd_error_system_call); - return -1; + return nread; } #else nread = fread (buf, 1, nbytes, f); @@ -320,7 +320,7 @@ cache_bread_1 (struct bfd *abfd, void *buf, file_ptr nbytes) if (nread < nbytes && ferror (f)) { bfd_set_error (bfd_error_system_call); - return -1; + return nread; } #endif if (nread < nbytes)