projects
/
gcc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[Ada] Refactor repeated code for real type attributes returning integers
[gcc.git]
/
libbacktrace
/
read.c
diff --git
a/libbacktrace/read.c
b/libbacktrace/read.c
index eb4852610223bb7d1fae40f4c4d96474af89a3d3..1a6052bf61396e3786dd7810854f462635cadea2 100644
(file)
--- a/
libbacktrace/read.c
+++ b/
libbacktrace/read.c
@@
-1,5
+1,5
@@
/* read.c -- File views without mmap.
/* read.c -- File views without mmap.
- Copyright (C) 2012-20
19
Free Software Foundation, Inc.
+ Copyright (C) 2012-20
20
Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without
Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without
@@
-50,7
+50,8
@@
backtrace_get_view (struct backtrace_state *state, int descriptor,
backtrace_error_callback error_callback,
void *data, struct backtrace_view *view)
{
backtrace_error_callback error_callback,
void *data, struct backtrace_view *view)
{
- ssize_t got;
+ uint64_t got;
+ ssize_t r;
if ((uint64_t) (size_t) size != size)
{
if ((uint64_t) (size_t) size != size)
{
@@
-70,15
+71,22
@@
backtrace_get_view (struct backtrace_state *state, int descriptor,
view->data = view->base;
view->len = size;
view->data = view->base;
view->len = size;
- got =
read (descriptor, view->base, size)
;
-
if (got < 0
)
+ got =
0
;
+
while (got < size
)
{
{
- error_callback (data, "read", errno);
- free (view->base);
- return 0;
+ r = read (descriptor, view->base, size - got);
+ if (r < 0)
+ {
+ error_callback (data, "read", errno);
+ free (view->base);
+ return 0;
+ }
+ if (r == 0)
+ break;
+ got += (uint64_t) r;
}
}
- if (
(size_t)
got < size)
+ if (got < size)
{
error_callback (data, "file too short", 0);
free (view->base);
{
error_callback (data, "file too short", 0);
free (view->base);