Skip to content

Commit 8652b67

Browse files
committed
simplify
Created using spr 1.3.4
1 parent 15f5450 commit 8652b67

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static void SetNonBlock(int fd) {
298298
}
299299

300300
bool IsAccessibleMemoryRange(uptr beg, uptr size) {
301-
for (uptr to_write = size; to_write;) {
301+
while (size) {
302302
// `read` from `sock_pair[0]` into a dummy buffer to free up the pipe buffer
303303
// for more `write` is slower than just recreating a pipe.
304304
int sock_pair[2];
@@ -313,14 +313,13 @@ bool IsAccessibleMemoryRange(uptr beg, uptr size) {
313313
SetNonBlock(sock_pair[1]);
314314

315315
int write_errno;
316-
uptr bytes_written =
317-
internal_write(sock_pair[1], reinterpret_cast<char *>(beg), to_write);
318-
if (internal_iserror(bytes_written, &write_errno)) {
316+
uptr w = internal_write(sock_pair[1], reinterpret_cast<char *>(beg), size);
317+
if (internal_iserror(w, &write_errno)) {
319318
CHECK_EQ(EFAULT, write_errno);
320319
return false;
321320
}
322-
beg += bytes_written;
323-
to_write -= bytes_written;
321+
size -= w;
322+
beg += w;
324323
}
325324

326325
return true;

0 commit comments

Comments
 (0)