Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp909691lqm; Wed, 1 May 2024 22:06:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpoFs1MmD+itsFuPm0gI0+XvssU0jaVEVWD0z7CZUcwWVJm9jG0H1uT9FDc67G2nFp0Pf2Ui0Cc/1s7djHjh7VwD9Og/zLi0ba3hPIxg== X-Google-Smtp-Source: AGHT+IG0u+9agNF6evieAPBjLtFKq77KvsYapE/e+6VrGOXTq/7yr4tD47tdIFaspFFU9mzCsRiR X-Received: by 2002:a17:90a:df04:b0:2b2:b99f:4d5b with SMTP id gp4-20020a17090adf0400b002b2b99f4d5bmr4951878pjb.18.1714626407039; Wed, 01 May 2024 22:06:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714626407; cv=pass; d=google.com; s=arc-20160816; b=ijnzEAIo0bxINQF3ykd9awDZ+e6hIeLwRLSArwAOPSPFCV87Zk/03CeYxMS12qDB9C H8UacoYtIBkSs3b7EMh1t8UejRU4DvgQemO2lJCXIVHpa4KZ8dZpUOYRy4ITwEDL9MoX jKiXlAURxUdfekdVS87c5GaSG0o8VQQyXgMkWm1Ku19FEmZB2GnwTUzbDvGWxzhMbYDJ AvX2NRZbhbltSjFyTOCiQuQpWEZ78qCGWFhQv8cD0Pxa0p0YawLBH6OPlnW0ZNNwqIbh ETW7MrEPoHFfxwf1UP8aVSsts9UP3d2UR0+IdL84gK7mL42wRxFNk5nCvBc/Zx/Q6XoG z8wA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=6XIylefjhMGlw6giRBdG9DxUt6yfGF+tcJ6Bmbp3i7s=; fh=nmu5+zjrjDGZWztgQRxutqL3dTXpWOxlwcOLN4zWq0c=; b=G1uehmvZJMYB2j+pDcFTxuLjtBHspIYu50yR0w6jms83gPs5eWliXD1uUy6XQOp3Dt PCqmkTt4drj+2/WrjXUd4sEU2f0YwvqqvupZiULbwu6xWQuIn2SXWB9RMX3uG8euxT0j pEWLMkHeQT5MYpk+VhPnfXaWLmZ0T58HiKUelxs0sZeYYsTePo8aYmYGyaqr3sYPjrkF h/HirdS+2mB6AtPHxVZ01sTSK4kWkRAt/RfJFR3Wgh+Dsi8Bqdsug9OaQ+fRJnbpn8Uy VkE89R6+wwtm8l9li60Vj/DoMuiPv24pYM6g5U4ZChvs9CpxGrIQrUvbGP4KVKxzVJPa B4bg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=Qjaog+Dw; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-165974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165974-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id o3-20020a17090a3d4300b002b2cea7f553si339412pjf.155.2024.05.01.22.06.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 22:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=Qjaog+Dw; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-165974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165974-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 082C6B2104A for ; Thu, 2 May 2024 05:06:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1FCD1F959; Thu, 2 May 2024 05:06:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="Qjaog+Dw" Received: from msa.smtpout.orange.fr (msa-217.smtpout.orange.fr [193.252.23.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B78B134B1; Thu, 2 May 2024 05:06:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.252.23.217 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714626395; cv=none; b=TNbn8vPlyrYSb7OttI9Y5DNNIe/2pFEunrTkedEaUHbDAuiRpyZ9d0s+AWCNSo7QZOMlleWRTBZpHuZcdXwE80E/xNx/DK+nBzU+88eRwb353opK9Pfxl4Z0HzTDNsJCLvkXhU2MvWJ2GirJvwVLDR7wCw6bJ2hlMgyqDwSUxVo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714626395; c=relaxed/simple; bh=i6vj/PwQB7gB7UJ91ISxfENpDqOjWzxS+DmVM14cbFI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CrVnXCa4Z+WMVOaMbBGBs7BlZ8SbRUkwVxcezA7Ynaj0+QrZnfmh7VNW57ha4EiXwSHAQOZzjdEfZS1P8wCCrjGyD4Gm+HL8/oTgaT/xxzWM22DwdE8Jj3gY0GpHAu0DdswG1fJrWZGbrbDRQp7QfnxbzdgWLMhtCzUQxDhGfZE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=Qjaog+Dw; arc=none smtp.client-ip=193.252.23.217 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from [192.168.1.37] ([86.243.17.157]) by smtp.orange.fr with ESMTPA id 2OeDsPOIB9Rhy2OeEs9jKt; Thu, 02 May 2024 07:06:24 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1714626384; bh=6XIylefjhMGlw6giRBdG9DxUt6yfGF+tcJ6Bmbp3i7s=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=Qjaog+DwHttjDLg3WOnG31H+yPjtNhVWhcTmXDYyBTPW2jTzf4zPceOpP6uzPZJSt yL2QZ+URtKOPLWwdoYa+z/Meqye3onroN3l5Me3g+6I2nvEUuHLeJ0+DboD5cl4BhA 6DTWrIcN6zLdgKhJj3RbmjHbcwNDIfJXUbaGeJLvuSWDGzDqE3h1CuQvbQvcHjk/bA xJVknUrsvRoeNM3eQ/44AdtZTDL7VVs1eVD/ThpOH4LRkekkIagJKMozH8cOrgz/yt 6+qHb+DgPXiXTmUy0JgFoTajMe8uZT3fiZKOgE9JV8YsPCUvZO2txONENyW8Dspa5R YnL35IpVxJgIA== X-ME-Helo: [192.168.1.37] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 02 May 2024 07:06:24 +0200 X-ME-IP: 86.243.17.157 Message-ID: <289aa316-5067-446e-96d8-7b318fa367a9@wanadoo.fr> Date: Thu, 2 May 2024 07:06:21 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] printk: cleanup deprecated uses of strncpy/strcpy To: Justin Stitt Cc: Petr Mladek , Steven Rostedt , John Ogness , Sergey Senozhatsky , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20240429-strncpy-kernel-printk-printk-c-v1-1-4da7926d7b69@google.com> <7cdc63b3-31cc-442c-8c2e-75adb2c76b52@wanadoo.fr> Content-Language: en-MW From: Christophe JAILLET In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 02/05/2024 à 01:18, Justin Stitt a écrit : > On Wed, May 1, 2024 at 2:39 PM Christophe JAILLET > wrote: >> Hi, >> >> Nit: The { } around each branch can now also be removed. > > There was one line before and there's one line now. In the block after the "else", yes, but now the block after the "if" is only 1 line. (it was 2 before). So, {} should now be omitted on both branches. - if (str[0] >= '0' && str[0] <= '9') { - strcpy(buf, "ttyS"); - strncpy(buf + 4, str, sizeof(buf) - 5); + if (isdigit(str[0])) { + scnprintf(buf, sizeof(buf), "ttyS%s", str); } else { - strncpy(buf, str, sizeof(buf) - 1); + strscpy(buf, str); } This is a really minor nitpick. Not sure you need to repost if there is no other comment. CJ > > I'll remove the brackets but I will briefly wait to see if any other > concerns come in. > > Thanks > >> >> CJ >> > >