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