Account for trailing bytes read from bfd_bread
authorAlan Modra <amodra@gmail.com>
Wed, 9 Jul 2014 10:34:40 +0000 (20:04 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 15 Jul 2014 04:18:08 +0000 (13:48 +0930)
* cache.c (cache_bread_1): Don't return -1 when fread returns
a positive value.

bfd/ChangeLog
bfd/cache.c

index 8c922aa..96f85f7 100644 (file)
@@ -1,5 +1,10 @@
 2014-07-15  Alan Modra  <amodra@gmail.com>
 
+       * cache.c (cache_bread_1): Don't return -1 when fread returns
+       a positive value.
+
+2014-07-15  Alan Modra  <amodra@gmail.com>
+
        * elflink.c (elf_merge_st_other): Update comments.  Simplify
        visibility handling.  Make isym const.  Move code modifying
        isym->st_other for --exclude-libs to..
index 27fe70a..ffda004 100644 (file)
@@ -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)