From patchwork Tue Mar 30 07:37:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gioh Kim X-Patchwork-Id: 12171893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5278FC43446 for ; Tue, 30 Mar 2021 07:39:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2831061959 for ; Tue, 30 Mar 2021 07:39:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231379AbhC3Hiq (ORCPT ); Tue, 30 Mar 2021 03:38:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231395AbhC3HiR (ORCPT ); Tue, 30 Mar 2021 03:38:17 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44B93C061762 for ; Tue, 30 Mar 2021 00:38:17 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id o19so17039938edc.3 for ; Tue, 30 Mar 2021 00:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T5srQ/60JF7ZiUGd4AoDyuQgYPEKKpRTj50Ou9B6W4A=; b=XgeSH8V2m5j94LepZ8Iv8Sjiv90ybPfz5YS/1AEQKcs2iZ+c1H/uqXwrFUaoZboRHk XnjRcVlC1x1AcYQceHUvJ93cB7AtuSI/hlwtHPmFbFtmMr3l/yfnlF8hNYr5qWup3UiT JM946+wzb2tGrzK4IUh/HCmQcTduwlaFuq/7pJO444yZkriBjIsZolNs1M+K+DIpC4sn yIVu1M0w411LcbHlGFPBsnOzumhgb+jL/7rxnpoljYkHWSF8xADdR7q2PWiZOv5x7Pvo c/rNoWiK7q4Xcs/XBrRsu1IGZId/AtQk4mtcQEdFU7bLmGi0mPkZlpHgqqOyrRkDE/ip Ar9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T5srQ/60JF7ZiUGd4AoDyuQgYPEKKpRTj50Ou9B6W4A=; b=CAXvuxcmhNqRAIlqLuXDcm5A8gXZqXT6kv9WkzdhCWaPCodPMN29CZ2pHeiVfvWzcm huIFp0OAeziENQF1cLt9o/HuE+lAikQMNbrcG+xGf9U1laPyJPA1uH1mDeL9iKHPkgKn L4sxdn3/ABRu5FZOFSVGjWdMgoS1azyeD+mkOlhdiApLTGAjV4J6vmo2XPNQojvmcrCr DmXCpIWwCNuPC4InCGjtUiLiOmAWkvHj3XphQYp2+9KQArUn720rlVmCqfI1VO5Ove7o JeTMoBJ1z30WNxcYeZTurWsPqdGFM9bEJn1ZlSU8PCFv/kuuN1Elj2DGrCBhR1+X0b7h GoKw== X-Gm-Message-State: AOAM530IbiDhSU+rdUOyyXlpYhwcqqQSVADl0UDWF5lYSVdkTdT4koj1 6a0KtMmYC/Xkxtfln6ZTU8c5RgWIHKl5Q3MG X-Google-Smtp-Source: ABdhPJzF2Qf76nCOB3pvPx83f4ecxiawHlqx5sBknkXDL72ure1LvmAMPEKLD2jTIzrotL7Wuqm0Dg== X-Received: by 2002:a50:ec96:: with SMTP id e22mr32324389edr.385.1617089895904; Tue, 30 Mar 2021 00:38:15 -0700 (PDT) Received: from gkim-laptop.fkb.profitbricks.net (ip5f5aeee5.dynamic.kabel-deutschland.de. [95.90.238.229]) by smtp.googlemail.com with ESMTPSA id a3sm9556180ejv.40.2021.03.30.00.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 00:38:15 -0700 (PDT) From: Gioh Kim To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Dima Stepanov Subject: [PATCHv2 for-next 24/24] block/rnbd: Use strscpy instead of strlcpy Date: Tue, 30 Mar 2021 09:37:52 +0200 Message-Id: <20210330073752.1465613-25-gi-oh.kim@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com> References: <20210330073752.1465613-1-gi-oh.kim@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Dima Stepanov During checkpatch analyzing the following warning message was found: WARNING:STRLCPY: Prefer strscpy over strlcpy - see: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Fix it by using strscpy calls instead of strlcpy. Signed-off-by: Dima Stepanov Signed-off-by: Jack Wang Reviewed-by: Chaitanya Kulkarni --- drivers/block/rnbd/rnbd-clt-sysfs.c | 6 +++--- drivers/block/rnbd/rnbd-clt.c | 4 ++-- drivers/block/rnbd/rnbd-srv.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c index b1d04115e049..3c3172af08da 100644 --- a/drivers/block/rnbd/rnbd-clt-sysfs.c +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c @@ -99,7 +99,7 @@ static int rnbd_clt_parse_map_options(const char *buf, size_t max_path_cnt, kfree(p); goto out; } - strlcpy(opt->sessname, p, NAME_MAX); + strscpy(opt->sessname, p, NAME_MAX); kfree(p); break; @@ -142,7 +142,7 @@ static int rnbd_clt_parse_map_options(const char *buf, size_t max_path_cnt, kfree(p); goto out; } - strlcpy(opt->pathname, p, NAME_MAX); + strscpy(opt->pathname, p, NAME_MAX); kfree(p); break; @@ -511,7 +511,7 @@ static int rnbd_clt_get_path_name(struct rnbd_clt_dev *dev, char *buf, int ret; char pathname[NAME_MAX], *s; - strlcpy(pathname, dev->pathname, sizeof(pathname)); + strscpy(pathname, dev->pathname, sizeof(pathname)); while ((s = strchr(pathname, '/'))) s[0] = '!'; diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 9d1bc49d5595..6e5d4a02a9b7 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -583,7 +583,7 @@ static int send_msg_open(struct rnbd_clt_dev *dev, enum wait_type wait) msg.hdr.type = cpu_to_le16(RNBD_MSG_OPEN); msg.access_mode = dev->access_mode; - strlcpy(msg.dev_name, dev->pathname, sizeof(msg.dev_name)); + strscpy(msg.dev_name, dev->pathname, sizeof(msg.dev_name)); WARN_ON(!rnbd_clt_get_dev(dev)); err = send_usr_msg(sess->rtrs, READ, iu, @@ -805,7 +805,7 @@ static struct rnbd_clt_session *alloc_sess(const char *sessname) sess = kzalloc_node(sizeof(*sess), GFP_KERNEL, NUMA_NO_NODE); if (!sess) return ERR_PTR(-ENOMEM); - strlcpy(sess->sessname, sessname, sizeof(sess->sessname)); + strscpy(sess->sessname, sessname, sizeof(sess->sessname)); atomic_set(&sess->busy, 0); mutex_init(&sess->lock); INIT_LIST_HEAD(&sess->devs_list); diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index 78bd0ce0ebf0..d6ec16d7211d 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -304,7 +304,7 @@ static int create_sess(struct rtrs_srv *rtrs) mutex_unlock(&sess_lock); srv_sess->rtrs = rtrs; - strlcpy(srv_sess->sessname, sessname, sizeof(srv_sess->sessname)); + strscpy(srv_sess->sessname, sessname, sizeof(srv_sess->sessname)); rtrs_srv_set_sess_priv(rtrs, srv_sess); @@ -443,7 +443,7 @@ static struct rnbd_srv_dev *rnbd_srv_init_srv_dev(const char *id) if (!dev) return ERR_PTR(-ENOMEM); - strlcpy(dev->id, id, sizeof(dev->id)); + strscpy(dev->id, id, sizeof(dev->id)); kref_init(&dev->kref); INIT_LIST_HEAD(&dev->sess_dev_list); mutex_init(&dev->lock); @@ -595,7 +595,7 @@ rnbd_srv_create_set_sess_dev(struct rnbd_srv_session *srv_sess, kref_init(&sdev->kref); - strlcpy(sdev->pathname, open_msg->dev_name, sizeof(sdev->pathname)); + strscpy(sdev->pathname, open_msg->dev_name, sizeof(sdev->pathname)); sdev->rnbd_dev = rnbd_dev; sdev->sess = srv_sess;