diff mbox series

[liburing,v2,5/5] liburing: improve fallocate typecasting

Message ID bbcd93f438c60073bb06ae7ab02f6ebd770ecdcb.1658748624.git.asml.silence@gmail.com (mailing list archive)
State New
Headers show
Series zerocopy send headers and tests | expand

Commit Message

Pavel Begunkov July 25, 2022, 11:33 a.m. UTC
Don't double cast int -> ptr -> int in io_uring_prep_fallocate(), assign
len directly.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 src/include/liburing.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Ammar Faizi July 25, 2022, 12:21 p.m. UTC | #1
On 7/25/22 6:33 PM, Pavel Begunkov wrote:
> Don't double cast int -> ptr -> int in io_uring_prep_fallocate(), assign
> len directly.
> 
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> ---
>   src/include/liburing.h | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
[...]
>   	io_uring_prep_rw(IORING_OP_FALLOCATE, sqe, fd,
> -			(const uintptr_t *) (unsigned long) len,
> -			(unsigned int) mode, (__u64) offset);
> +			0, (unsigned int) mode, (__u64) offset);

nit: instead of 0 it's better to use NULL. No?

> +	sqe->addr = (__u64) len;

This one looks simpler than a double cast.

Reviewed-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
diff mbox series

Patch

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 20cd308..cffdabd 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -601,10 +601,9 @@  static inline void io_uring_prep_files_update(struct io_uring_sqe *sqe,
 static inline void io_uring_prep_fallocate(struct io_uring_sqe *sqe, int fd,
 					   int mode, off_t offset, off_t len)
 {
-
 	io_uring_prep_rw(IORING_OP_FALLOCATE, sqe, fd,
-			(const uintptr_t *) (unsigned long) len,
-			(unsigned int) mode, (__u64) offset);
+			0, (unsigned int) mode, (__u64) offset);
+	sqe->addr = (__u64) len;
 }
 
 static inline void io_uring_prep_openat(struct io_uring_sqe *sqe, int dfd,