Commit c7920fa8 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-16264: Eliminate unsafe os_aio_userdata_t type cast

parent 8be3794b
...@@ -1350,6 +1350,12 @@ struct os_aio_userdata_t ...@@ -1350,6 +1350,12 @@ struct os_aio_userdata_t
fil_node_t* node; fil_node_t* node;
IORequest type; IORequest type;
void* message; void* message;
os_aio_userdata_t(fil_node_t*node, IORequest type, void*message) :
node(node), type(type), message(message) {}
/** Construct from tpool::aiocb::m_userdata[] */
os_aio_userdata_t(const char *buf) { memcpy((void*)this, buf, sizeof*this); }
}; };
/** /**
NOTE! Use the corresponding macro os_aio(), not directly this function! NOTE! Use the corresponding macro os_aio(), not directly this function!
......
...@@ -3883,7 +3883,7 @@ extern void fil_aio_callback(os_aio_userdata_t *data); ...@@ -3883,7 +3883,7 @@ extern void fil_aio_callback(os_aio_userdata_t *data);
static void io_callback(tpool::aiocb* cb) static void io_callback(tpool::aiocb* cb)
{ {
ut_a(cb->m_err == DB_SUCCESS); ut_a(cb->m_err == DB_SUCCESS);
os_aio_userdata_t data = *(os_aio_userdata_t*)cb->m_userdata; os_aio_userdata_t data(cb->m_userdata);
/* Return cb back to cache*/ /* Return cb back to cache*/
if (cb->m_opcode == tpool::aio_opcode::AIO_PREAD) { if (cb->m_opcode == tpool::aio_opcode::AIO_PREAD) {
if (read_slots->contains(cb)) { if (read_slots->contains(cb)) {
......
...@@ -137,7 +137,7 @@ struct aiocb ...@@ -137,7 +137,7 @@ struct aiocb
int m_err; int m_err;
void *m_internal; void *m_internal;
task m_internal_task; task m_internal_task;
char m_userdata[MAX_AIO_USERDATA_LEN]; alignas(8) char m_userdata[MAX_AIO_USERDATA_LEN];
aiocb() : m_internal_task(nullptr, nullptr) aiocb() : m_internal_task(nullptr, nullptr)
{} {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment