]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
io_uring: convert cmd_to_io_kiocb() macro to function
authorCaleb Sander Mateos <csander@purestorage.com>
Fri, 28 Feb 2025 23:03:04 +0000 (16:03 -0700)
committerJens Axboe <axboe@kernel.dk>
Sat, 1 Mar 2025 02:14:54 +0000 (19:14 -0700)
The cmd_to_io_kiocb() macro applies a pointer cast to its input without
parenthesizing it. Currently all inputs are variable names, so this has
the intended effect. But since casts have relatively high precedence,
the macro would apply the cast to the wrong value if the input was a
pointer addition, for example.

Turn the macro into a static inline function to ensure the pointer cast
is applied to the full input value.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Link: https://lore.kernel.org/r/20250228230305.630885-1-csander@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/io_uring_types.h

index 432c98ff52ee90756a935275d9aabf8d30d46b6e..72aac84dca93d23d945615f690d58a45a73b2faa 100644 (file)
@@ -607,7 +607,11 @@ static inline void io_kiocb_cmd_sz_check(size_t cmd_sz)
        io_kiocb_cmd_sz_check(sizeof(cmd_type)) , \
        ((cmd_type *)&(req)->cmd) \
 )
-#define cmd_to_io_kiocb(ptr)   ((struct io_kiocb *) ptr)
+
+static inline struct io_kiocb *cmd_to_io_kiocb(void *ptr)
+{
+       return ptr;
+}
 
 struct io_kiocb {
        union {