]> git.ipfire.org Git - thirdparty/qemu.git/commit
hw/rdma/vmw/pvrdma_cmd: Use correct struct in query_port()
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 19 Oct 2023 14:47:47 +0000 (15:47 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Tue, 24 Oct 2023 06:14:34 +0000 (09:14 +0300)
commit28facf15989f43a4b6e801e6349c03603a78a6a0
tree957e19ef65392b6b9897d62e096e4ab9e6b0c468
parentfdeedb886aa40e2e632f365c46c53c3380135073
hw/rdma/vmw/pvrdma_cmd: Use correct struct in query_port()

In query_port() we pass the address of a local pvrdma_port_attr
struct to the rdma_query_backend_port() function.  Unfortunately,
rdma_backend_query_port() wants a pointer to a struct ibv_port_attr,
and the two are not the same length.

Coverity spotted this (CID 1507146): pvrdma_port_attr is 48 bytes
long, and ibv_port_attr is 52 bytes, because it has a few extra
fields at the end.

Fortunately, all we do with the attrs struct after the call is to
read a few specific fields out of it which are all at the same
offsets in both structs, so we can simply make the local variable the
correct type.  This also lets us drop the cast (which should have
been a bit of a warning flag that we were doing something wrong
here).

We do however need to add extra casts for the fields of the
struct that are enums: clang will complain about the implicit
cast to a different enum type otherwise.

Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(cherry picked from commit 4ab9a7429bf7507fba4b96b97d4147628c91ba14)
hw/rdma/vmw/pvrdma_cmd.c