diff options
author | Bodong Wang <bodong@mellanox.com> | 2016-08-21 19:47:59 +0300 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2016-08-25 10:41:47 -0400 |
commit | 5982a88a19c4de633b05c2b9d24e4bcab94f17a6 (patch) | |
tree | a7ed87d40ccbc5dfacc00b1f61f699e766ef87f3 | |
parent | 0be978ea2bfaf203c35334b090bddb280de62611 (diff) | |
download | libibverbs-5982a88a19c4de633b05c2b9d24e4bcab94f17a6.tar.gz |
Fix ibv_cmd_query_device_ex to return valid output
Make sure to return valid output by memset the extended fields to zero.
No need to deal with specific fields any more.
Currently, extended fields will be assigned to some value or 0 depending
on response from the command. When adding a new extended field, relevant
variables must be cleared if no response got from the kernel.
Signed-off-by: Bodong Wang <bodong@mellanox.com>
Reviewed-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r-- | src/cmd.c | 9 |
1 files changed, 1 insertions, 8 deletions
@@ -163,6 +163,7 @@ int ibv_cmd_query_device_ex(struct ibv_context *context, cmd->comp_mask = 0; cmd->reserved = 0; memset(attr->orig_attr.fw_ver, 0, sizeof(attr->orig_attr.fw_ver)); + memset(&attr->comp_mask, 0, attr_size - sizeof(attr->orig_attr)); err = write(context->cmd_fd, cmd, cmd_size); if (err != cmd_size) return errno; @@ -184,8 +185,6 @@ int ibv_cmd_query_device_ex(struct ibv_context *context, resp->odp_caps.per_transport_caps.uc_odp_caps; attr->odp_caps.per_transport_caps.ud_odp_caps = resp->odp_caps.per_transport_caps.ud_odp_caps; - } else { - memset(&attr->odp_caps, 0, sizeof(attr->odp_caps)); } } @@ -196,8 +195,6 @@ int ibv_cmd_query_device_ex(struct ibv_context *context, offsetof(struct ibv_query_device_resp_ex, timestamp_mask) + sizeof(resp->timestamp_mask)) attr->completion_timestamp_mask = resp->timestamp_mask; - else - attr->completion_timestamp_mask = 0; } if (attr_size >= offsetof(struct ibv_device_attr_ex, hca_core_clock) + @@ -206,8 +203,6 @@ int ibv_cmd_query_device_ex(struct ibv_context *context, offsetof(struct ibv_query_device_resp_ex, hca_core_clock) + sizeof(resp->hca_core_clock)) attr->hca_core_clock = resp->hca_core_clock; - else - attr->hca_core_clock = 0; } if (attr_size >= offsetof(struct ibv_device_attr_ex, device_cap_flags_ex) + @@ -216,8 +211,6 @@ int ibv_cmd_query_device_ex(struct ibv_context *context, offsetof(struct ibv_query_device_resp_ex, device_cap_flags_ex) + sizeof(resp->device_cap_flags_ex)) attr->device_cap_flags_ex = resp->device_cap_flags_ex; - else - attr->device_cap_flags_ex = 0; } return 0; |