@@ -108,8 +108,8 @@ impl FileDesc {
108
108
target_os = "vita" ,
109
109
target_os = "nuttx"
110
110
) ) ) ]
111
- pub fn read_vectored ( & self , mut bufs : & mut [ IoSliceMut < ' _ > ] ) -> io:: Result < usize > {
112
- IoSliceMut :: limit_slices ( & mut bufs, max_iov ( ) ) ;
111
+ pub fn read_vectored ( & self , bufs : & mut [ IoSliceMut < ' _ > ] ) -> io:: Result < usize > {
112
+ let bufs = io :: limit_slices_mut! ( bufs, max_iov( ) ) ;
113
113
let ret = cvt ( unsafe {
114
114
libc:: readv (
115
115
self . as_raw_fd ( ) ,
@@ -199,12 +199,8 @@ impl FileDesc {
199
199
target_os = "netbsd" ,
200
200
target_os = "openbsd" , // OpenBSD 2.7
201
201
) ) ]
202
- pub fn read_vectored_at (
203
- & self ,
204
- mut bufs : & mut [ IoSliceMut < ' _ > ] ,
205
- offset : u64 ,
206
- ) -> io:: Result < usize > {
207
- IoSliceMut :: limit_slices ( & mut bufs, max_iov ( ) ) ;
202
+ pub fn read_vectored_at ( & self , bufs : & mut [ IoSliceMut < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
203
+ let bufs = io:: limit_slices_mut!( bufs, max_iov( ) ) ;
208
204
let ret = cvt ( unsafe {
209
205
libc:: preadv (
210
206
self . as_raw_fd ( ) ,
@@ -241,11 +237,7 @@ impl FileDesc {
241
237
// passing 64-bits parameters to syscalls, so we fallback to the default
242
238
// implementation if `preadv` is not available.
243
239
#[ cfg( all( target_os = "android" , target_pointer_width = "64" ) ) ]
244
- pub fn read_vectored_at (
245
- & self ,
246
- mut bufs : & mut [ IoSliceMut < ' _ > ] ,
247
- offset : u64 ,
248
- ) -> io:: Result < usize > {
240
+ pub fn read_vectored_at ( & self , bufs : & mut [ IoSliceMut < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
249
241
syscall ! (
250
242
fn preadv(
251
243
fd: libc:: c_int,
@@ -255,7 +247,7 @@ impl FileDesc {
255
247
) -> isize ;
256
248
) ;
257
249
258
- IoSliceMut :: limit_slices ( & mut bufs, max_iov ( ) ) ;
250
+ let bufs = io :: limit_slices_mut! ( bufs, max_iov( ) ) ;
259
251
let ret = cvt ( unsafe {
260
252
preadv (
261
253
self . as_raw_fd ( ) ,
@@ -271,11 +263,7 @@ impl FileDesc {
271
263
// FIXME(#115199): Rust currently omits weak function definitions
272
264
// and its metadata from LLVM IR.
273
265
#[ no_sanitize( cfi) ]
274
- pub fn read_vectored_at (
275
- & self ,
276
- mut bufs : & mut [ IoSliceMut < ' _ > ] ,
277
- offset : u64 ,
278
- ) -> io:: Result < usize > {
266
+ pub fn read_vectored_at ( & self , bufs : & mut [ IoSliceMut < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
279
267
weak ! (
280
268
fn preadv64(
281
269
fd: libc:: c_int,
@@ -287,7 +275,7 @@ impl FileDesc {
287
275
288
276
match preadv64. get ( ) {
289
277
Some ( preadv) => {
290
- IoSliceMut :: limit_slices ( & mut bufs, max_iov ( ) ) ;
278
+ let bufs = io :: limit_slices_mut! ( bufs, max_iov( ) ) ;
291
279
let ret = cvt ( unsafe {
292
280
preadv (
293
281
self . as_raw_fd ( ) ,
@@ -312,11 +300,7 @@ impl FileDesc {
312
300
// These versions may be newer than the minimum supported versions of OS's we support so we must
313
301
// use "weak" linking.
314
302
#[ cfg( target_vendor = "apple" ) ]
315
- pub fn read_vectored_at (
316
- & self ,
317
- mut bufs : & mut [ IoSliceMut < ' _ > ] ,
318
- offset : u64 ,
319
- ) -> io:: Result < usize > {
303
+ pub fn read_vectored_at ( & self , bufs : & mut [ IoSliceMut < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
320
304
weak ! (
321
305
fn preadv(
322
306
fd: libc:: c_int,
@@ -328,7 +312,7 @@ impl FileDesc {
328
312
329
313
match preadv. get ( ) {
330
314
Some ( preadv) => {
331
- IoSliceMut :: limit_slices ( & mut bufs, max_iov ( ) ) ;
315
+ let bufs = io :: limit_slices_mut! ( bufs, max_iov( ) ) ;
332
316
let ret = cvt ( unsafe {
333
317
preadv (
334
318
self . as_raw_fd ( ) ,
@@ -360,8 +344,8 @@ impl FileDesc {
360
344
target_os = "vita" ,
361
345
target_os = "nuttx"
362
346
) ) ) ]
363
- pub fn write_vectored ( & self , mut bufs : & [ IoSlice < ' _ > ] ) -> io:: Result < usize > {
364
- IoSlice :: limit_slices ( & mut bufs, max_iov ( ) ) ;
347
+ pub fn write_vectored ( & self , bufs : & [ IoSlice < ' _ > ] ) -> io:: Result < usize > {
348
+ let bufs = io :: limit_slices! ( bufs, max_iov( ) ) ;
365
349
let ret = cvt ( unsafe {
366
350
libc:: writev (
367
351
self . as_raw_fd ( ) ,
@@ -430,8 +414,8 @@ impl FileDesc {
430
414
target_os = "netbsd" ,
431
415
target_os = "openbsd" , // OpenBSD 2.7
432
416
) ) ]
433
- pub fn write_vectored_at ( & self , mut bufs : & [ IoSlice < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
434
- IoSlice :: limit_slices ( & mut bufs, max_iov ( ) ) ;
417
+ pub fn write_vectored_at ( & self , bufs : & [ IoSlice < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
418
+ let bufs = io :: limit_slices! ( bufs, max_iov( ) ) ;
435
419
let ret = cvt ( unsafe {
436
420
libc:: pwritev (
437
421
self . as_raw_fd ( ) ,
@@ -468,7 +452,7 @@ impl FileDesc {
468
452
// passing 64-bits parameters to syscalls, so we fallback to the default
469
453
// implementation if `pwritev` is not available.
470
454
#[ cfg( all( target_os = "android" , target_pointer_width = "64" ) ) ]
471
- pub fn write_vectored_at ( & self , mut bufs : & [ IoSlice < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
455
+ pub fn write_vectored_at ( & self , bufs : & [ IoSlice < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
472
456
syscall ! (
473
457
fn pwritev(
474
458
fd: libc:: c_int,
@@ -478,7 +462,7 @@ impl FileDesc {
478
462
) -> isize ;
479
463
) ;
480
464
481
- IoSlice :: limit_slices ( & mut bufs, max_iov ( ) ) ;
465
+ let bufs = io :: limit_slices! ( bufs, max_iov( ) ) ;
482
466
let ret = cvt ( unsafe {
483
467
pwritev (
484
468
self . as_raw_fd ( ) ,
@@ -491,7 +475,7 @@ impl FileDesc {
491
475
}
492
476
493
477
#[ cfg( all( target_os = "android" , target_pointer_width = "32" ) ) ]
494
- pub fn write_vectored_at ( & self , mut bufs : & [ IoSlice < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
478
+ pub fn write_vectored_at ( & self , bufs : & [ IoSlice < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
495
479
weak ! (
496
480
fn pwritev64(
497
481
fd: libc:: c_int,
@@ -503,7 +487,7 @@ impl FileDesc {
503
487
504
488
match pwritev64. get ( ) {
505
489
Some ( pwritev) => {
506
- IoSlice :: limit_slices ( & mut bufs, max_iov ( ) ) ;
490
+ let bufs = io :: limit_slices! ( bufs, max_iov( ) ) ;
507
491
let ret = cvt ( unsafe {
508
492
pwritev (
509
493
self . as_raw_fd ( ) ,
@@ -528,7 +512,7 @@ impl FileDesc {
528
512
// These versions may be newer than the minimum supported versions of OS's we support so we must
529
513
// use "weak" linking.
530
514
#[ cfg( target_vendor = "apple" ) ]
531
- pub fn write_vectored_at ( & self , mut bufs : & [ IoSlice < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
515
+ pub fn write_vectored_at ( & self , bufs : & [ IoSlice < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
532
516
weak ! (
533
517
fn pwritev(
534
518
fd: libc:: c_int,
@@ -540,7 +524,7 @@ impl FileDesc {
540
524
541
525
match pwritev. get ( ) {
542
526
Some ( pwritev) => {
543
- IoSlice :: limit_slices ( & mut bufs, max_iov ( ) ) ;
527
+ let bufs = io :: limit_slices! ( bufs, max_iov( ) ) ;
544
528
let ret = cvt ( unsafe {
545
529
pwritev (
546
530
self . as_raw_fd ( ) ,
0 commit comments