* [PATCH] io_uring: convert cmd_to_io_kiocb() macro to function
@ 2025-02-28 23:03 Caleb Sander Mateos
2025-03-01 2:23 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Caleb Sander Mateos @ 2025-02-28 23:03 UTC (permalink / raw)
To: Jens Axboe, Pavel Begunkov; +Cc: Caleb Sander Mateos, io-uring, linux-kernel
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 <[email protected]>
---
include/linux/io_uring_types.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h
index 432c98ff52ee..72aac84dca93 100644
--- a/include/linux/io_uring_types.h
+++ b/include/linux/io_uring_types.h
@@ -605,11 +605,15 @@ static inline void io_kiocb_cmd_sz_check(size_t cmd_sz)
}
#define io_kiocb_to_cmd(req, cmd_type) ( \
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 {
/*
* NOTE! Each of the io_kiocb union members has the file pointer
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] io_uring: convert cmd_to_io_kiocb() macro to function
2025-02-28 23:03 [PATCH] io_uring: convert cmd_to_io_kiocb() macro to function Caleb Sander Mateos
@ 2025-03-01 2:23 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2025-03-01 2:23 UTC (permalink / raw)
To: Pavel Begunkov, Caleb Sander Mateos; +Cc: io-uring, linux-kernel
On Fri, 28 Feb 2025 16:03:04 -0700, Caleb Sander Mateos wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] io_uring: convert cmd_to_io_kiocb() macro to function
commit: 09fdd35162c289f354326a55d552a8858f6e8072
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-01 2:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-28 23:03 [PATCH] io_uring: convert cmd_to_io_kiocb() macro to function Caleb Sander Mateos
2025-03-01 2:23 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox