@@ -135,7 +135,8 @@ impl FileDescription for AnonSocket {
135
135
136
136
// Always succeed on read size 0.
137
137
if request_byte_size == 0 {
138
- ecx. read_byte_helper ( ptr, bytes. to_vec ( ) , Ok ( 0 ) , dest) ?;
138
+ let result = Ok ( 0 ) ;
139
+ ecx. read_byte_helper ( ptr, bytes. to_vec ( ) , result, dest) ?;
139
140
return Ok ( ( ) ) ;
140
141
}
141
142
@@ -149,7 +150,8 @@ impl FileDescription for AnonSocket {
149
150
if self . peer_fd ( ) . upgrade ( ) . is_none ( ) {
150
151
// Socketpair with no peer and empty buffer.
151
152
// 0 bytes successfully read indicates end-of-file.
152
- ecx. read_byte_helper ( ptr, bytes. to_vec ( ) , Ok ( 0 ) , dest) ?;
153
+ let result = Ok ( 0 ) ;
154
+ ecx. read_byte_helper ( ptr, bytes. to_vec ( ) , result, dest) ?;
153
155
return Ok ( ( ) ) ;
154
156
} else {
155
157
if self . is_nonblock {
@@ -158,12 +160,8 @@ impl FileDescription for AnonSocket {
158
160
// EAGAIN or EWOULDBLOCK can be returned for socket,
159
161
// POSIX.1-2001 allows either error to be returned for this case.
160
162
// Since there is no ErrorKind for EAGAIN, WouldBlock is used.
161
- ecx. read_byte_helper (
162
- ptr,
163
- bytes. to_vec ( ) ,
164
- Err ( Error :: from ( ErrorKind :: WouldBlock ) ) ,
165
- dest,
166
- ) ?;
163
+ let result = Err ( Error :: from ( ErrorKind :: WouldBlock ) ) ;
164
+ ecx. read_byte_helper ( ptr, bytes. to_vec ( ) , result, dest) ?;
167
165
return Ok ( ( ) ) ;
168
166
} else {
169
167
// Blocking socketpair with writer and empty buffer.
@@ -196,7 +194,8 @@ impl FileDescription for AnonSocket {
196
194
ecx. check_and_update_readiness ( & peer_fd) ?;
197
195
}
198
196
199
- ecx. read_byte_helper ( ptr, bytes. to_vec ( ) , Ok ( actual_read_size) , dest) ?;
197
+ let result = Ok ( actual_read_size) ;
198
+ ecx. read_byte_helper ( ptr, bytes. to_vec ( ) , result, dest) ?;
200
199
return Ok ( ( ) ) ;
201
200
}
202
201
@@ -212,15 +211,17 @@ impl FileDescription for AnonSocket {
212
211
// Always succeed on write size 0.
213
212
// ("If count is zero and fd refers to a file other than a regular file, the results are not specified.")
214
213
if write_size == 0 {
215
- ecx. write_byte_helper ( Ok ( 0 ) , dest) ?;
214
+ let result = Ok ( 0 ) ;
215
+ ecx. write_byte_helper ( result, dest) ?;
216
216
return Ok ( ( ) ) ;
217
217
}
218
218
219
219
// We are writing to our peer's readbuf.
220
220
let Some ( peer_fd) = self . peer_fd ( ) . upgrade ( ) else {
221
221
// If the upgrade from Weak to Rc fails, it indicates that all read ends have been
222
222
// closed.
223
- ecx. write_byte_helper ( Err ( Error :: from ( ErrorKind :: BrokenPipe ) ) , dest) ?;
223
+ let result = Err ( Error :: from ( ErrorKind :: BrokenPipe ) ) ;
224
+ ecx. write_byte_helper ( result, dest) ?;
224
225
return Ok ( ( ) ) ;
225
226
} ;
226
227
@@ -235,7 +236,8 @@ impl FileDescription for AnonSocket {
235
236
if available_space == 0 {
236
237
if self . is_nonblock {
237
238
// Non-blocking socketpair with a full buffer.
238
- ecx. write_byte_helper ( Err ( Error :: from ( ErrorKind :: WouldBlock ) ) , dest) ?;
239
+ let result = Err ( Error :: from ( ErrorKind :: WouldBlock ) ) ;
240
+ ecx. write_byte_helper ( result, dest) ?;
239
241
return Ok ( ( ) ) ;
240
242
} else {
241
243
// Blocking socketpair with a full buffer.
@@ -257,7 +259,8 @@ impl FileDescription for AnonSocket {
257
259
// The kernel does this even if the fd was already readable before, so we follow suit.
258
260
ecx. check_and_update_readiness ( & peer_fd) ?;
259
261
260
- ecx. write_byte_helper ( Ok ( actual_write_size) , dest) ?;
262
+ let result = Ok ( actual_write_size) ;
263
+ ecx. write_byte_helper ( result, dest) ?;
261
264
return Ok ( ( ) ) ;
262
265
}
263
266
}
0 commit comments