@@ -135,7 +135,8 @@ impl FileDescription for AnonSocket {
135135
136136 // Always succeed on read size 0.
137137 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) ?;
139140 return Ok ( ( ) ) ;
140141 }
141142
@@ -149,7 +150,8 @@ impl FileDescription for AnonSocket {
149150 if self . peer_fd ( ) . upgrade ( ) . is_none ( ) {
150151 // Socketpair with no peer and empty buffer.
151152 // 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) ?;
153155 return Ok ( ( ) ) ;
154156 } else {
155157 if self . is_nonblock {
@@ -158,12 +160,8 @@ impl FileDescription for AnonSocket {
158160 // EAGAIN or EWOULDBLOCK can be returned for socket,
159161 // POSIX.1-2001 allows either error to be returned for this case.
160162 // 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) ?;
167165 return Ok ( ( ) ) ;
168166 } else {
169167 // Blocking socketpair with writer and empty buffer.
@@ -196,7 +194,8 @@ impl FileDescription for AnonSocket {
196194 ecx. check_and_update_readiness ( & peer_fd) ?;
197195 }
198196
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) ?;
200199 return Ok ( ( ) ) ;
201200 }
202201
@@ -212,15 +211,17 @@ impl FileDescription for AnonSocket {
212211 // Always succeed on write size 0.
213212 // ("If count is zero and fd refers to a file other than a regular file, the results are not specified.")
214213 if write_size == 0 {
215- ecx. write_byte_helper ( Ok ( 0 ) , dest) ?;
214+ let result = Ok ( 0 ) ;
215+ ecx. write_byte_helper ( result, dest) ?;
216216 return Ok ( ( ) ) ;
217217 }
218218
219219 // We are writing to our peer's readbuf.
220220 let Some ( peer_fd) = self . peer_fd ( ) . upgrade ( ) else {
221221 // If the upgrade from Weak to Rc fails, it indicates that all read ends have been
222222 // 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) ?;
224225 return Ok ( ( ) ) ;
225226 } ;
226227
@@ -235,7 +236,8 @@ impl FileDescription for AnonSocket {
235236 if available_space == 0 {
236237 if self . is_nonblock {
237238 // 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) ?;
239241 return Ok ( ( ) ) ;
240242 } else {
241243 // Blocking socketpair with a full buffer.
@@ -257,7 +259,8 @@ impl FileDescription for AnonSocket {
257259 // The kernel does this even if the fd was already readable before, so we follow suit.
258260 ecx. check_and_update_readiness ( & peer_fd) ?;
259261
260- ecx. write_byte_helper ( Ok ( actual_write_size) , dest) ?;
262+ let result = Ok ( actual_write_size) ;
263+ ecx. write_byte_helper ( result, dest) ?;
261264 return Ok ( ( ) ) ;
262265 }
263266}
0 commit comments