Skip to content

Commit

Permalink
IB/core: Replace setting the zero values in ib_uverbs_ex_query_device
Browse files Browse the repository at this point in the history
The setting to zero during variable initialization eliminates
the need to explicitly set to zero variables and structures.

Signed-off-by: Leon Romanovsky <[email protected]>
Reviewed-by: Matan Barak <[email protected]>
Signed-off-by: Doug Ledford <[email protected]>
  • Loading branch information
Leon Romanovsky authored and Doug Ledford committed Mar 21, 2016
1 parent 3f0393a commit 2953f42
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions drivers/infiniband/core/uverbs_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3600,9 +3600,9 @@ int ib_uverbs_ex_query_device(struct ib_uverbs_file *file,
struct ib_udata *ucore,
struct ib_udata *uhw)
{
struct ib_uverbs_ex_query_device_resp resp;
struct ib_uverbs_ex_query_device_resp resp = { {0} };
struct ib_uverbs_ex_query_device cmd;
struct ib_device_attr attr;
struct ib_device_attr attr = {0};
int err;

if (ucore->inlen < sizeof(cmd))
Expand All @@ -3623,14 +3623,11 @@ int ib_uverbs_ex_query_device(struct ib_uverbs_file *file,
if (ucore->outlen < resp.response_length)
return -ENOSPC;

memset(&attr, 0, sizeof(attr));

err = ib_dev->query_device(ib_dev, &attr, uhw);
if (err)
return err;

copy_query_dev_fields(file, ib_dev, &resp.base, &attr);
resp.comp_mask = 0;

if (ucore->outlen < resp.response_length + sizeof(resp.odp_caps))
goto end;
Expand All @@ -3643,9 +3640,6 @@ int ib_uverbs_ex_query_device(struct ib_uverbs_file *file,
attr.odp_caps.per_transport_caps.uc_odp_caps;
resp.odp_caps.per_transport_caps.ud_odp_caps =
attr.odp_caps.per_transport_caps.ud_odp_caps;
resp.odp_caps.reserved = 0;
#else
memset(&resp.odp_caps, 0, sizeof(resp.odp_caps));
#endif
resp.response_length += sizeof(resp.odp_caps);

Expand All @@ -3663,8 +3657,5 @@ int ib_uverbs_ex_query_device(struct ib_uverbs_file *file,

end:
err = ib_copy_to_udata(ucore, &resp, resp.response_length);
if (err)
return err;

return 0;
return err;
}

0 comments on commit 2953f42

Please sign in to comment.