]> git.baikalelectronics.ru Git - kernel.git/commitdiff
nvme: move from strlcpy with unused retval to strscpy
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 18 Aug 2022 21:00:52 +0000 (23:00 +0200)
committerChristoph Hellwig <hch@lst.de>
Mon, 19 Sep 2022 09:33:53 +0000 (11:33 +0200)
Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/core.c
drivers/nvme/host/fabrics.c
drivers/nvme/target/admin-cmd.c
drivers/nvme/target/discovery.c

index 1128816646958a51ec331825b92b4b21ca5f1989..8c9c1176624da775e7802e911e0262aba290da3a 100644 (file)
@@ -2696,7 +2696,7 @@ static void nvme_init_subnqn(struct nvme_subsystem *subsys, struct nvme_ctrl *ct
        if(!(ctrl->quirks & NVME_QUIRK_IGNORE_DEV_SUBNQN)) {
                nqnlen = strnlen(id->subnqn, NVMF_NQN_SIZE);
                if (nqnlen > 0 && nqnlen < NVMF_NQN_SIZE) {
-                       strlcpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE);
+                       strscpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE);
                        return;
                }
 
index 10cc4a8146027933a7d8a9b7b88f25eeda65049b..61637c1dd72224843dce2cabc88a18e6601a1fba 100644 (file)
@@ -49,7 +49,7 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn)
                goto out_unlock;
 
        kref_init(&host->ref);
-       strlcpy(host->nqn, hostnqn, NVMF_NQN_SIZE);
+       strscpy(host->nqn, hostnqn, NVMF_NQN_SIZE);
 
        list_add_tail(&host->list, &nvmf_hosts);
 out_unlock:
index fc8a957fad0ac06ad3a4a6ea1a1b167a0d4662b7..c8a061ce3ee566f95f7665ba6ad03d56edb58c8b 100644 (file)
@@ -449,7 +449,7 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
        if (req->port->inline_data_size)
                id->sgls |= cpu_to_le32(1 << 20);
 
-       strlcpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn));
+       strscpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn));
 
        /*
         * Max command capsule size is sqe + in-capsule data size.
index c2162eef8ce1a204bc9f8e993d8cafef86350085..668d257fa98636dc1785e7b5f6bb6b35e8188ab9 100644 (file)
@@ -292,7 +292,7 @@ static void nvmet_execute_disc_identify(struct nvmet_req *req)
 
        id->oaes = cpu_to_le32(NVMET_DISC_AEN_CFG_OPTIONAL);
 
-       strlcpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn));
+       strscpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn));
 
        status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));