nvme: remove zeroout memset call for struct
authorChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Wed, 16 Jun 2021 22:15:52 +0000 (15:15 -0700)
committerChristoph Hellwig <hch@lst.de>
Thu, 17 Jun 2021 13:51:21 +0000 (15:51 +0200)
Declare and initialize structure variables to zero values so that we can
remove zeroout memset calls in the host/core.c.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/core.c

index 177cae4..c7ef0b6 100644 (file)
@@ -721,9 +721,7 @@ EXPORT_SYMBOL_GPL(__nvme_check_ready);
 
 static int nvme_toggle_streams(struct nvme_ctrl *ctrl, bool enable)
 {
-       struct nvme_command c;
-
-       memset(&c, 0, sizeof(c));
+       struct nvme_command c = { };
 
        c.directive.opcode = nvme_admin_directive_send;
        c.directive.nsid = cpu_to_le32(NVME_NSID_ALL);
@@ -748,9 +746,8 @@ static int nvme_enable_streams(struct nvme_ctrl *ctrl)
 static int nvme_get_stream_params(struct nvme_ctrl *ctrl,
                                  struct streams_directive_params *s, u32 nsid)
 {
-       struct nvme_command c;
+       struct nvme_command c = { };
 
-       memset(&c, 0, sizeof(c));
        memset(s, 0, sizeof(*s));
 
        c.directive.opcode = nvme_admin_directive_recv;
@@ -1460,10 +1457,9 @@ static int nvme_features(struct nvme_ctrl *dev, u8 op, unsigned int fid,
                unsigned int dword11, void *buffer, size_t buflen, u32 *result)
 {
        union nvme_result res = { 0 };
-       struct nvme_command c;
+       struct nvme_command c = { };
        int ret;
 
-       memset(&c, 0, sizeof(c));
        c.features.opcode = op;
        c.features.fid = cpu_to_le32(fid);
        c.features.dword11 = cpu_to_le32(dword11);
@@ -1591,9 +1587,8 @@ int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo)
 static void nvme_init_integrity(struct gendisk *disk, u16 ms, u8 pi_type,
                                u32 max_integrity_segments)
 {
-       struct blk_integrity integrity;
+       struct blk_integrity integrity = { };
 
-       memset(&integrity, 0, sizeof(integrity));
        switch (pi_type) {
        case NVME_NS_DPS_PI_TYPE3:
                integrity.profile = &t10_pi_type3_crc;
@@ -1964,13 +1959,12 @@ static int nvme_send_ns_pr_command(struct nvme_ns *ns, struct nvme_command *c,
 static int nvme_pr_command(struct block_device *bdev, u32 cdw10,
                                u64 key, u64 sa_key, u8 op)
 {
-       struct nvme_command c;
+       struct nvme_command c = { };
        u8 data[16] = { 0, };
 
        put_unaligned_le64(key, &data[0]);
        put_unaligned_le64(sa_key, &data[8]);
 
-       memset(&c, 0, sizeof(c));
        c.common.opcode = op;
        c.common.cdw10 = cpu_to_le32(cdw10);
 
@@ -2042,9 +2036,8 @@ int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,
                bool send)
 {
        struct nvme_ctrl *ctrl = data;
-       struct nvme_command cmd;
+       struct nvme_command cmd = { };
 
-       memset(&cmd, 0, sizeof(cmd));
        if (send)
                cmd.common.opcode = nvme_admin_security_send;
        else