@@ -919,10 +919,15 @@ IOURINGINLINE void io_uring_prep_statx(struct io_uring_sqe *sqe, int dfd,
919
919
sqe -> statx_flags = (__u32 ) flags ;
920
920
}
921
921
922
+ IOURINGINLINE __u32 __io_uring_cap_len (size_t len ) {
923
+ size_t mask = - (size_t )(len > UINT32_MAX );
924
+ return (len & ~mask ) | (UINT32_MAX & mask );
925
+ }
926
+
922
927
IOURINGINLINE void io_uring_prep_fadvise (struct io_uring_sqe * sqe , int fd ,
923
928
__u64 offset , __u32 len , int advice )
924
929
{
925
- io_uring_prep_rw (IORING_OP_FADVISE , sqe , fd , NULL , ( __u32 ) len , offset );
930
+ io_uring_prep_rw (IORING_OP_FADVISE , sqe , fd , NULL , __io_uring_cap_len ( len ) , offset );
926
931
sqe -> fadvise_advice = (__u32 ) advice ;
927
932
}
928
933
@@ -951,7 +956,7 @@ IOURINGINLINE void io_uring_prep_madvise64(struct io_uring_sqe *sqe, void *addr,
951
956
IOURINGINLINE void io_uring_prep_send (struct io_uring_sqe * sqe , int sockfd ,
952
957
const void * buf , size_t len , int flags )
953
958
{
954
- io_uring_prep_rw (IORING_OP_SEND , sqe , sockfd , buf , ( __u32 ) len , 0 );
959
+ io_uring_prep_rw (IORING_OP_SEND , sqe , sockfd , buf , __io_uring_cap_len ( len ) , 0 );
955
960
sqe -> msg_flags = (__u32 ) flags ;
956
961
}
957
962
@@ -983,7 +988,7 @@ IOURINGINLINE void io_uring_prep_send_zc(struct io_uring_sqe *sqe, int sockfd,
983
988
const void * buf , size_t len , int flags ,
984
989
unsigned zc_flags )
985
990
{
986
- io_uring_prep_rw (IORING_OP_SEND_ZC , sqe , sockfd , buf , ( __u32 ) len , 0 );
991
+ io_uring_prep_rw (IORING_OP_SEND_ZC , sqe , sockfd , buf , __io_uring_cap_len ( len ) , 0 );
987
992
sqe -> msg_flags = (__u32 ) flags ;
988
993
sqe -> ioprio = zc_flags ;
989
994
}
@@ -1021,7 +1026,7 @@ IOURINGINLINE void io_uring_prep_sendmsg_zc_fixed(struct io_uring_sqe *sqe,
1021
1026
IOURINGINLINE void io_uring_prep_recv (struct io_uring_sqe * sqe , int sockfd ,
1022
1027
void * buf , size_t len , int flags )
1023
1028
{
1024
- io_uring_prep_rw (IORING_OP_RECV , sqe , sockfd , buf , ( __u32 ) len , 0 );
1029
+ io_uring_prep_rw (IORING_OP_RECV , sqe , sockfd , buf , __io_uring_cap_len ( len ) , 0 );
1025
1030
sqe -> msg_flags = (__u32 ) flags ;
1026
1031
}
1027
1032
@@ -1131,7 +1136,7 @@ IOURINGINLINE void io_uring_prep_provide_buffers(struct io_uring_sqe *sqe,
1131
1136
void * addr , int len , int nr ,
1132
1137
int bgid , int bid )
1133
1138
{
1134
- io_uring_prep_rw (IORING_OP_PROVIDE_BUFFERS , sqe , nr , addr , ( __u32 ) len ,
1139
+ io_uring_prep_rw (IORING_OP_PROVIDE_BUFFERS , sqe , nr , addr , __io_uring_cap_len ( len ) ,
1135
1140
(__u64 ) bid );
1136
1141
sqe -> buf_group = (__u16 ) bgid ;
1137
1142
}
0 commit comments