From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4B5F7ECAAA1 for ; Tue, 30 Aug 2022 07:23:47 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4MGzLn61frz3c8p for ; Tue, 30 Aug 2022 17:23:45 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=209.85.208.41; helo=mail-ed1-f41.google.com; envelope-from=jirislaby@gmail.com; receiver=) Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4MGzLL4Y60z2xBV for ; Tue, 30 Aug 2022 17:23:22 +1000 (AEST) Received: by mail-ed1-f41.google.com with SMTP id a36so9190480edf.5 for ; Tue, 30 Aug 2022 00:23:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=h92OFoHcscLoVZdNmDKj0YVmJDx8MKtyLOQI76zzz+M=; b=ho+poF5pDlV0PzKfgrKO3EfTNOpTnEEBcy6rzY2KFpD8UC9kRewovgSRY3atk5pt7P Vu3ObvzhnulblV0mRcJSW/g63HZ2HOL64Y8H07QaeNdUczStteWsiKddwW+21/et/XfA mrvlDjdy9zLKkQWt+clFrW9foPcZMS3aqbx1sTnNaCcwryyydcPvq/YXduievnnD4Xbj 5ntdFfiRYN89LpZorg/cbGY0L6d+DnHnYcDWAvLCWVsgXCyIAFTTfyneg+8vYF/ZeDGm 5ui5sKWJu+XK3D9q62bCfkIO7cBExpZJ2FqsG3qhGSy1peuyxKwG2oeLQFp0l7MAFp2K /Byw== X-Gm-Message-State: ACgBeo2Mfnoej8FlwkfpTa/KuI6d8/KtNxztsorFTqUvOC1VdiTaoxOW FuIvLCIC7Gc5V9pAJntW8aU= X-Google-Smtp-Source: AA6agR6GdO78X7ShA7eIwVF55Gd83NZLVU+aV19Oza8mJ9lSkrZ242TTINijF+n3YBED4WKcswXFwA== X-Received: by 2002:a05:6402:451:b0:446:7349:f9e8 with SMTP id p17-20020a056402045100b004467349f9e8mr19853745edw.180.1661844197211; Tue, 30 Aug 2022 00:23:17 -0700 (PDT) Received: from ?IPV6:2a0b:e7c0:0:107::70f? ([2a0b:e7c0:0:107::70f]) by smtp.gmail.com with ESMTPSA id p23-20020a056402045700b00447c646ad1asm6907975edw.57.2022.08.30.00.23.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Aug 2022 00:23:16 -0700 (PDT) Message-ID: <5df0c2fb-0eb4-e0fd-a517-b7ea1d4a8f4e@kernel.org> Date: Tue, 30 Aug 2022 09:23:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH] tty: move from strlcpy with unused retval to strscpy Content-Language: en-US To: Wolfram Sang , linux-kernel@vger.kernel.org References: <20220818210113.7469-1-wsa+renesas@sang-engineering.com> From: Jiri Slaby In-Reply-To: <20220818210113.7469-1-wsa+renesas@sang-engineering.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sparclinux@vger.kernel.org, Greg Kroah-Hartman , linuxppc-dev@lists.ozlabs.org, "David S. Miller" , linux-serial@vger.kernel.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 18. 08. 22, 23:01, 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. Reviewed-by: Jiri Slaby > Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ > Signed-off-by: Wolfram Sang > --- > drivers/tty/hvc/hvcs.c | 2 +- > drivers/tty/serial/earlycon.c | 6 +++--- > drivers/tty/serial/serial_core.c | 2 +- > drivers/tty/serial/sunsu.c | 6 +++--- > drivers/tty/serial/sunzilog.c | 6 +++--- > 5 files changed, 11 insertions(+), 11 deletions(-) > > diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c > index 9b7e8246a464..b79ce8d34f11 100644 > --- a/drivers/tty/hvc/hvcs.c > +++ b/drivers/tty/hvc/hvcs.c > @@ -839,7 +839,7 @@ static void hvcs_set_pi(struct hvcs_partner_info *pi, struct hvcs_struct *hvcsd) > hvcsd->p_partition_ID = pi->partition_ID; > > /* copy the null-term char too */ > - strlcpy(hvcsd->p_location_code, pi->location_code, > + strscpy(hvcsd->p_location_code, pi->location_code, > sizeof(hvcsd->p_location_code)); > } > > diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c > index 88d08ba1ca83..a5f380584cda 100644 > --- a/drivers/tty/serial/earlycon.c > +++ b/drivers/tty/serial/earlycon.c > @@ -67,7 +67,7 @@ static void __init earlycon_init(struct earlycon_device *device, > if (*s) > earlycon->index = simple_strtoul(s, NULL, 10); > len = s - name; > - strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name))); > + strscpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name))); > earlycon->data = &early_console_dev; > } > > @@ -123,7 +123,7 @@ static int __init parse_options(struct earlycon_device *device, char *options) > device->baud = simple_strtoul(options, NULL, 0); > length = min(strcspn(options, " ") + 1, > (size_t)(sizeof(device->options))); > - strlcpy(device->options, options, length); > + strscpy(device->options, options, length); > } > > return 0; > @@ -304,7 +304,7 @@ int __init of_setup_earlycon(const struct earlycon_id *match, > > if (options) { > early_console_dev.baud = simple_strtoul(options, NULL, 0); > - strlcpy(early_console_dev.options, options, > + strscpy(early_console_dev.options, options, > sizeof(early_console_dev.options)); > } > earlycon_init(&early_console_dev, match->name); > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > index 12c87cd201a7..3561a160cbd5 100644 > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -2497,7 +2497,7 @@ uart_report_port(struct uart_driver *drv, struct uart_port *port) > "MMIO 0x%llx", (unsigned long long)port->mapbase); > break; > default: > - strlcpy(address, "*unknown*", sizeof(address)); > + strscpy(address, "*unknown*", sizeof(address)); > break; > } > > diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c > index 84d545e5a8c7..d5dcb612804e 100644 > --- a/drivers/tty/serial/sunsu.c > +++ b/drivers/tty/serial/sunsu.c > @@ -1217,13 +1217,13 @@ static int sunsu_kbd_ms_init(struct uart_sunsu_port *up) > serio->id.type = SERIO_RS232; > if (up->su_type == SU_PORT_KBD) { > serio->id.proto = SERIO_SUNKBD; > - strlcpy(serio->name, "sukbd", sizeof(serio->name)); > + strscpy(serio->name, "sukbd", sizeof(serio->name)); > } else { > serio->id.proto = SERIO_SUN; > serio->id.extra = 1; > - strlcpy(serio->name, "sums", sizeof(serio->name)); > + strscpy(serio->name, "sums", sizeof(serio->name)); > } > - strlcpy(serio->phys, > + strscpy(serio->phys, > (!(up->port.line & 1) ? "su/serio0" : "su/serio1"), > sizeof(serio->phys)); > > diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c > index c14275d83b0b..c44cf613ff1a 100644 > --- a/drivers/tty/serial/sunzilog.c > +++ b/drivers/tty/serial/sunzilog.c > @@ -1307,13 +1307,13 @@ static void sunzilog_register_serio(struct uart_sunzilog_port *up) > serio->id.type = SERIO_RS232; > if (up->flags & SUNZILOG_FLAG_CONS_KEYB) { > serio->id.proto = SERIO_SUNKBD; > - strlcpy(serio->name, "zskbd", sizeof(serio->name)); > + strscpy(serio->name, "zskbd", sizeof(serio->name)); > } else { > serio->id.proto = SERIO_SUN; > serio->id.extra = 1; > - strlcpy(serio->name, "zsms", sizeof(serio->name)); > + strscpy(serio->name, "zsms", sizeof(serio->name)); > } > - strlcpy(serio->phys, > + strscpy(serio->phys, > ((up->flags & SUNZILOG_FLAG_CONS_KEYB) ? > "zs/serio0" : "zs/serio1"), > sizeof(serio->phys)); -- js suse labs