From a32ba316651820be8d593b3cf3c6d89537d0cff1 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 23 Apr 2018 15:34:20 -0700 Subject: [PATCH] vhost/nvme: remove cmd and cqe magic numbers Replace the hard-coded 64 and 16 constants, which are the size of the submission queue entry and completion queue entry, with equivalent sizeof expressions. Change-Id: I5a9d8fc1ab98276312445f0699aae3d86beee705 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/408762 Reviewed-by: Changpeng Liu Reviewed-by: Dariusz Stojaczyk Reviewed-by: Jim Harris Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker --- lib/vhost/rte_vhost/vhost_user.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vhost/rte_vhost/vhost_user.c b/lib/vhost/rte_vhost/vhost_user.c index 7018f327f..80a6e4f0e 100644 --- a/lib/vhost/rte_vhost/vhost_user.c +++ b/lib/vhost/rte_vhost/vhost_user.c @@ -1185,10 +1185,10 @@ vhost_user_msg_handler(int vid, int fd) if (!dev->is_nvme) { dev->is_nvme = 1; } - memcpy(cmd, &msg.payload.nvme.cmd, 64); + memcpy(cmd, msg.payload.nvme.cmd.req, sizeof(cmd)); ret = vhost_user_nvme_admin_passthrough(dev, cmd, cqe, buf); - memcpy(&msg.payload.nvme.cmd, &cqe, 16); - msg.size = 16; + memcpy(msg.payload.nvme.cmd.cqe, cqe, sizeof(cqe)); + msg.size = sizeof(cqe); /* NVMe Identify Command */ if (cmd[0] == 0x06) { memcpy(msg.payload.nvme.buf, &buf, 4096);