Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3921174rwa; Tue, 23 Aug 2022 12:32:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR77L3L2KSFInJV5BILovnceGSVdj/SeujDj5CPbTds77bigvqKkA5Y+eZETOzSefqoPKnqQ X-Received: by 2002:a05:6402:3324:b0:446:7bcc:6a93 with SMTP id e36-20020a056402332400b004467bcc6a93mr4977691eda.174.1661283176556; Tue, 23 Aug 2022 12:32:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661283176; cv=none; d=google.com; s=arc-20160816; b=lLYtFTAyfR63v3rkXlJC9NfR/OQCt1r5MRCFuNCjVCKcF8kGGGM8dmtGahbfc2Svuu zB4SgGfojREo62cZ/H6wT5T5KKFub5q+zimvCpWuMsJmWzhgnlIGYqYFmP+8ewstNVOA 2L5Eo3njYpfW0Avu3fC8RguCbKZoE5yP4qvo5zHw9HYYFbk0V6ZNAlsZfcPYvwCTG/Bs L4EO1TuH+74tDaeUB4K4s9XgXC2HMQq8iLyQgY9xx3FXLnW2V2VS/TDUwgAlxiyAbYGR C5Cm1d8BhDXhbUovphOqztUcZZpclaVBn3mq0iY1PpcAHx1Q9Lb8BjBYVi/bYcDmDdTC Z3bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qvB0bpEIT2sSe62uvVtXIxNIVxXN5Cn+lAxSxr60fic=; b=M9rRatHqP0BfDLbrmvxopXFEGIdQ73bMQuCmrMwBznN8BVf7Fb+JfOaBJJhYixUtdR qoF6BfYAsuZwe+sdibfObLVP/zoO6oHT1CUKvICHssrepouGvLkYpO+/HJF917P99jUE 1JDCloHvclKh9QIENhkphu99eerqU/McrFK36MgsFUGtcbmy/DLbT25NSzDJ+I7aecR+ TD/DR7KeO+ijaTZSoUAOEi06YTEvcYLNHqlk5AZ8zRh6WOYC216BuMGo2eYzaRLi7qNy 6+cfj/viNreTB9pHb5co1LXjLJoORKer9Pi+5T5nZ2rRbMEy93hSjIwWrJ17mI4tmax/ sWtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sCpmYXaD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr2-20020a170906d54200b007341ad4b028si510709ejc.642.2022.08.23.12.32.29; Tue, 23 Aug 2022 12:32:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sCpmYXaD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231421AbiHWTLF (ORCPT + 99 others); Tue, 23 Aug 2022 15:11:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232249AbiHWTKT (ORCPT ); Tue, 23 Aug 2022 15:10:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ADDE72877; Tue, 23 Aug 2022 10:48:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 743C66162A; Tue, 23 Aug 2022 17:46:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D02D1C433C1; Tue, 23 Aug 2022 17:46:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661276805; bh=+Pmlr84ILXzSyfNtmT4XWQ44Hi8a4+P3uTpYyORdvXw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=sCpmYXaDTgSTLECpnsoy1jyQRIUuY46NuMGbp/wFxkqlTrKs3QrMM9PhvWJ60UfKi j325vCefiQ68NcM8VETleqzzklPlR2Xk5WTODIl+bO/sPAWEz+uegKyxu5mBH6keit M+MGyK4Go/PbFq/TvNpSnxjI0GeG+9X3+04TwsCSz7Hxz5g3PZNTtnImTiEfBFNwUF KUz0cZ0NThWxzDbJIrnln4zNPmtPqBROHCebay/4d96oZnB4lvnihbzheVOe3ku0vM nhYWlY725tQm09ENuibV09xXeGEtd7aBHMelkwzlGLK872Xx+GKgcnvPZORHiq2MQF lZHruNLCd2epA== Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-333b049f231so399625827b3.1; Tue, 23 Aug 2022 10:46:45 -0700 (PDT) X-Gm-Message-State: ACgBeo2ql3XksCg4NhsTXwhSKRUg5DO7YboChFB+SZEkvY1lMjl66oP9 A5JGXsmeUyGdv0FQ7xTKnqx/0hHJ6hPnVI/npLQ= X-Received: by 2002:a05:6902:725:b0:695:b0c7:a248 with SMTP id l5-20020a056902072500b00695b0c7a248mr10341711ybt.389.1661276804849; Tue, 23 Aug 2022 10:46:44 -0700 (PDT) MIME-Version: 1.0 References: <20220818210027.6964-1-wsa+renesas@sang-engineering.com> In-Reply-To: <20220818210027.6964-1-wsa+renesas@sang-engineering.com> From: Song Liu Date: Tue, 23 Aug 2022 10:46:33 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] md: move from strlcpy with unused retval to strscpy To: Wolfram Sang Cc: open list , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, linux-raid Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 18, 2022 at 2:00 PM Wolfram Sang wrote: > > 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 Looks good to me. Alasdair and Mike, This patch touches both dm and md code. Would you like me to take it via the md tree? Thanks, Song > --- > drivers/md/dm-ioctl.c | 4 ++-- > drivers/md/md.c | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c > index 98976aaa9db9..6148fb73ccb4 100644 > --- a/drivers/md/dm-ioctl.c > +++ b/drivers/md/dm-ioctl.c > @@ -921,9 +921,9 @@ static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param) > * Sneakily write in both the name and the uuid > * while we have the cell. > */ > - strlcpy(param->name, hc->name, sizeof(param->name)); > + strscpy(param->name, hc->name, sizeof(param->name)); > if (hc->uuid) > - strlcpy(param->uuid, hc->uuid, sizeof(param->uuid)); > + strscpy(param->uuid, hc->uuid, sizeof(param->uuid)); > else > param->uuid[0] = '\0'; > > diff --git a/drivers/md/md.c b/drivers/md/md.c > index afaf36b2f6ab..4d019ac0a549 100644 > --- a/drivers/md/md.c > +++ b/drivers/md/md.c > @@ -5743,7 +5743,7 @@ static int add_named_array(const char *val, const struct kernel_param *kp) > len--; > if (len >= DISK_NAME_LEN) > return -E2BIG; > - strscpy(buf, val, len+1); > + strscpy(buf, val, len + 1); > if (strncmp(buf, "md_", 3) == 0) > return md_alloc_and_put(0, buf); > if (strncmp(buf, "md", 2) == 0 && > -- > 2.35.1 >