55#include "query.h"
66#include "io_uring.h"
77
8- #define IO_MAX_QUERY_SIZE (sizeof(struct io_uring_query_opcode))
8+ union io_query_data {
9+ struct io_uring_query_opcode opcodes ;
10+ };
11+
12+ #define IO_MAX_QUERY_SIZE sizeof(union io_query_data)
913#define IO_MAX_QUERY_ENTRIES 1000
1014
11- static ssize_t io_query_ops (void * data )
15+ static ssize_t io_query_ops (union io_query_data * data )
1216{
13- struct io_uring_query_opcode * e = data ;
14-
15- BUILD_BUG_ON (sizeof (* e ) > IO_MAX_QUERY_SIZE );
17+ struct io_uring_query_opcode * e = & data -> opcodes ;
1618
1719 e -> nr_request_opcodes = IORING_OP_LAST ;
1820 e -> nr_register_opcodes = IORING_REGISTER_LAST ;
@@ -24,7 +26,7 @@ static ssize_t io_query_ops(void *data)
2426}
2527
2628static int io_handle_query_entry (struct io_ring_ctx * ctx ,
27- void * data , void __user * uhdr ,
29+ union io_query_data * data , void __user * uhdr ,
2830 u64 * next_entry )
2931{
3032 struct io_uring_query_hdr hdr ;
@@ -73,19 +75,19 @@ static int io_handle_query_entry(struct io_ring_ctx *ctx,
7375
7476int io_query (struct io_ring_ctx * ctx , void __user * arg , unsigned nr_args )
7577{
76- char entry_buffer [ IO_MAX_QUERY_SIZE ] ;
78+ union io_query_data entry_buffer ;
7779 void __user * uhdr = arg ;
7880 int ret , nr = 0 ;
7981
80- memset (entry_buffer , 0 , sizeof (entry_buffer ));
82+ memset (& entry_buffer , 0 , sizeof (entry_buffer ));
8183
8284 if (nr_args )
8385 return - EINVAL ;
8486
8587 while (uhdr ) {
8688 u64 next_hdr ;
8789
88- ret = io_handle_query_entry (ctx , entry_buffer , uhdr , & next_hdr );
90+ ret = io_handle_query_entry (ctx , & entry_buffer , uhdr , & next_hdr );
8991 if (ret )
9092 return ret ;
9193 uhdr = u64_to_user_ptr (next_hdr );
0 commit comments