IB/core: Replace setting the zero values in ib_uverbs_ex_query_device
authorLeon Romanovsky <leonro@mellanox.com>
Tue, 23 Feb 2016 08:25:24 +0000 (10:25 +0200)
committerDoug Ledford <dledford@redhat.com>
Mon, 21 Mar 2016 20:32:36 +0000 (16:32 -0400)
The setting to zero during variable initialization eliminates
the need to explicitly set to zero variables and structures.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/uverbs_cmd.c

index 3638c787cb7c3834eef3ab6ee061f34f1481f60b..bb1b93c0a0168fefa590e0bc65ed73c871235ab4 100644 (file)
@@ -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))
@@ -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;
@@ -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);
 
@@ -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;
 }