From nobody Fri Apr 10 22:21:40 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95354C00140 for ; Thu, 18 Aug 2022 21:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346247AbiHRVMs (ORCPT ); Thu, 18 Aug 2022 17:12:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346723AbiHRVKZ (ORCPT ); Thu, 18 Aug 2022 17:10:25 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EF47D8B01 for ; Thu, 18 Aug 2022 14:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=k1; bh=QzjvisubQtpjUfjoA3zi5xIV/S5 puA8JW5PpatWWyQs=; b=AqKu2qJCVlgTfPAJZvMwgPo5kEHn2mdDcJxubwGD6wV Eyrp2j7xwtFy0Ejb5pbQ4CvZ8w90h98BzXt4Ls2vNMQ3hK/b9asfLTgVnY8nKjhY YM5Uh4J3mw14kBaHVELf1A57WnKInW03cI0TJcxgeeROeghGSNEEM55oXwTz4Gso = Received: (qmail 3962705 invoked from network); 18 Aug 2022 23:02:00 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 18 Aug 2022 23:02:00 +0200 X-UD-Smtp-Session: l3s3148p1@gAvqSormV/Yucref From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang Subject: [PATCH] init: move from strlcpy with unused retval to strscpy Date: Thu, 18 Aug 2022 23:01:59 +0200 Message-Id: <20220818210200.8203-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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-=3DwgfRnXz0W3D37d01q3JFkr_i_uTL=3DV6A6= G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Wolfram Sang --- init/do_mounts.c | 4 ++-- init/main.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/init/do_mounts.c b/init/do_mounts.c index 7058e14ad5f7..811e94daf0a8 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -296,7 +296,7 @@ EXPORT_SYMBOL_GPL(name_to_dev_t); =20 static int __init root_dev_setup(char *line) { - strlcpy(saved_root_name, line, sizeof(saved_root_name)); + strscpy(saved_root_name, line, sizeof(saved_root_name)); return 1; } =20 @@ -343,7 +343,7 @@ static int __init split_fs_names(char *page, size_t siz= e, char *names) int count =3D 1; char *p =3D page; =20 - strlcpy(p, root_fs_names, size); + strscpy(p, root_fs_names, size); while (*p++) { if (p[-1] =3D=3D ',') { p[-1] =3D '\0'; diff --git a/init/main.c b/init/main.c index 91642a4e69be..6da14b8ab376 100644 --- a/init/main.c +++ b/init/main.c @@ -422,7 +422,7 @@ static void __init setup_boot_config(void) if (!data) data =3D xbc_get_embedded_bootconfig(&size); =20 - strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE); + strscpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE); err =3D parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL, bootconfig_params); =20 @@ -762,7 +762,7 @@ void __init parse_early_param(void) return; =20 /* All fall through to do_early_param. */ - strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE); + strscpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE); parse_early_options(tmp_cmdline); done =3D 1; } --=20 2.35.1