On 03/21/2018 07:40 AM, Marcel Apfelbaum wrote:
Fix some enum castings and extra parentheses.

Reported-by: Michael S. Tsirkin <m...@redhat.com>
Signed-off-by: Marcel Apfelbaum <mar...@redhat.com>
---
  hw/rdma/vmw/pvrdma_cmd.c  | 5 +++--
  hw/rdma/vmw/pvrdma_main.c | 5 +++--
  2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c
index 293dfed29f..25f747a190 100644
--- a/hw/rdma/vmw/pvrdma_cmd.c
+++ b/hw/rdma/vmw/pvrdma_cmd.c
@@ -73,7 +73,7 @@ static void *pvrdma_map_to_pdir(PCIDevice *pdev, uint64_t 
pdir_dma,
      tbl_idx = 1;
      addr_idx = 1;
      while (addr_idx < nchunks) {
-        if ((tbl_idx == (TARGET_PAGE_SIZE / sizeof(uint64_t)))) {
+        if (tbl_idx == (TARGET_PAGE_SIZE / sizeof(uint64_t))) {

Can't you still simplify that further to

if (tbl_idx == TARGET_PAGE_SIZE / sizeof(uint64_t)) {

@@ -292,7 +292,8 @@ static void init_ports(PVRDMADev *dev, Error **errp)
      memset(dev->rdma_dev_res.ports, 0, sizeof(dev->rdma_dev_res.ports));
for (i = 0; i < MAX_PORTS; i++) {
-        dev->rdma_dev_res.ports[i].state = PVRDMA_PORT_DOWN;
+        dev->rdma_dev_res.ports[i].state =
+            (enum ibv_port_state)PVRDMA_PORT_DOWN;

This one looks suspicious - shouldn't you instead be using IBV_PORT_DOWN instead of having to cast? (Even if IBV_PORT_DOWN and PVRDMA_PORT_DOWN both have the value of 1 for now, the compiler warning is telling you that either one of the two enums can change independently in the future, and using a cast to shut up the compiler feels unsafe).

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Reply via email to