diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-03-28 14:05:49 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2014-05-08 10:18:30 -0600 |
commit | 81ad11e32c40b9d53e578054e2885087f347c337 (patch) | |
tree | 4af5acfa29e4ed65b07bbf80805b5665a4196e52 /libiberty/simple-object.c | |
parent | PR sanitizer/56781 * Makefile.def: Set bootstrap=true; for host fixincludes. ... (diff) | |
download | binutils-gdb-81ad11e32c40b9d53e578054e2885087f347c337.tar.gz binutils-gdb-81ad11e32c40b9d53e578054e2885087f347c337.tar.bz2 binutils-gdb-81ad11e32c40b9d53e578054e2885087f347c337.zip |
2014-03-28 Richard Biener <rguenther@suse.de>
libiberty/
* simple-object.c (simple_object_internal_read): Handle
EINTR and short reads.
lto-plugin/
* lto-plugin.c (process_symtab): Handle EINTR and short reads.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208898 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty/simple-object.c')
-rw-r--r-- | libiberty/simple-object.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/libiberty/simple-object.c b/libiberty/simple-object.c index fde3454dd42..263d174051d 100644 --- a/libiberty/simple-object.c +++ b/libiberty/simple-object.c @@ -63,8 +63,6 @@ simple_object_internal_read (int descriptor, off_t offset, unsigned char *buffer, size_t size, const char **errmsg, int *err) { - ssize_t got; - if (lseek (descriptor, offset, SEEK_SET) < 0) { *errmsg = "lseek"; @@ -72,15 +70,26 @@ simple_object_internal_read (int descriptor, off_t offset, return 0; } - got = read (descriptor, buffer, size); - if (got < 0) + do { - *errmsg = "read"; - *err = errno; - return 0; + ssize_t got = read (descriptor, buffer, size); + if (got == 0) + break; + else if (got > 0) + { + buffer += got; + size -= got; + } + else if (errno != EINTR) + { + *errmsg = "read"; + *err = errno; + return 0; + } } + while (size > 0); - if ((size_t) got < size) + if (size > 0) { *errmsg = "file too short"; *err = 0; |