Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1929487rdb; Sun, 4 Feb 2024 07:19:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGF6ZZ029FmQbmpsh3SlLI44JWBqXc9fUc75RToBJQwy0T0+Tdod9ncC8liaR/Iu087yS/+ X-Received: by 2002:a05:6358:5d83:b0:178:7542:1a58 with SMTP id s3-20020a0563585d8300b0017875421a58mr16502085rwm.7.1707059960046; Sun, 04 Feb 2024 07:19:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707059960; cv=pass; d=google.com; s=arc-20160816; b=juKFU9/M8qEdXnWfwAkqD7Pl9/22GI9eglUCFoXP7X9r/KbgOrt9XCJ+1jWMWB99Pt QJ7P8GdmDUFXNo0JTvUgbNvifxmmeoH7PkZ45N4AAvWqBB3lrbLm1QwPb1e61hFGNrWJ EIQ/cYGdVRX6oz1livoZT7szYg/nhUgaAT6oq7S0BpbxZ9znxJ3jeA0X03T98ogWj6iN G58arkWE1y+P2a4v/H+IWhocLX/fdlnALsl1CztP8kMAV/0i824sw4AzuEf8wZD76c7b rIReUsCB9+gDagXLK4dgfV20kI0HUe7lOnxctC5sxtBytl0bjYPgI5VuJhWdzqnUf7Zh b5Ew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=a2jOuxVhRVerkuhXyqafdLTpk9jKFJhm3MINzr4qOwM=; fh=eSqzsiB7je9nKB65UUQShEHWdmIj5OqP2PFvfeL7Skw=; b=lXzrRASBWIPumrEqNvXSOWNli/1N/p5M8bIKZdiTSHfmh/oRzcV58QYnqLrPCVg0qJ IYpa/TG0tMD8wiGw/36wz+pLc1+yMQsiWT3vwzIn2Tf7vveYBwyOPeCT8bgwuKhg+Z/5 bSE8UHKNbfHQG3BadZ50NHX0eO3f7b7XSdnKFlX6BOtcrfNpXnHgQqX33Ozd8rGK+Q3R Ayk6ewu180XxUPLUfAQBNIpijsTKMW8na9Qji9RY7SgL4JGpuracLk9Ev/S6jO9AXWFt D3tv7cT2n5YqnATmLBVoo2r+8DDnVhmUu8wXrhsm+22MuFclJyxB3SpEg8KYN6PAAcqu 1+iQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TBLdwUHG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-51748-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51748-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVpzFIp8z+eCQiFYO1ZPe8Za5xSg9/Js7hQy6fEWpdyhHsu8VabowTe8UTYbOM2jvVJFFXZEM7TB01qUPQudT7XfWlccjoJky9fuVC2bw== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id bw15-20020a056a02048f00b005dc19ac7173si120949pgb.21.2024.02.04.07.19.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 07:19:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51748-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TBLdwUHG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-51748-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51748-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 E9C71B215AF for ; Sun, 4 Feb 2024 15:19:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 956ED225CF; Sun, 4 Feb 2024 15:19:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TBLdwUHG" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6766225AA; Sun, 4 Feb 2024 15:19:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707059946; cv=none; b=NRlLKHu0IzJj1ECLoo5IuKAcffiYk9CQ99T6JJJ+7UzYf2oQPc8g/+v+0IJvBGK/+gCRgmLc3n4L50tFr8nUtoKP0AbhL69+jUdBGlgNl+cT7n+q3qDivUhiqziBEj3KYrdbNuV8oTrxaU9q9lfo16mn4JvBvCO5aeg4kIlTsGE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707059946; c=relaxed/simple; bh=VAwbFSaHpu8yNPzwtRSQDyXC7qrgpVyDPy/iQqXhAhM=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AtFlWdTSyTTPiFczDxHxqiiccJuAp9+AzhbAKD5fK95JJK9CvfkpnapDqehew8CLGA+6Mm8KduMMeiPnbsDqxCLzGJwS00oj4Szdq9+0WDkqb+YsuZ3X2F1uKlkBpMGmN2HD6k63GLB0jtgCgPMhyXvpAGSvxlM6OHiYNVdY68w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TBLdwUHG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48471C433C7; Sun, 4 Feb 2024 15:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707059946; bh=VAwbFSaHpu8yNPzwtRSQDyXC7qrgpVyDPy/iQqXhAhM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=TBLdwUHGhO9+zhHGUj5626zUZFBcaCgrv1rmdfXnBzufVXHE1S6DXrE6afHw4mqzj Tn4LsXVO6WTVePEcnQWgUm15Ttbs0m6Jl9g2tTOF8oqAzZjwGL33HpPb+VaPRBFFoD LqcHC5nz4L3tm5h0QZqbkODc5JoBf9LXrLR7hFbtLLUcBOwE0b0nOOadlJffLiF5en DFVGoOwVMoPuDXH/E0FCcmO03/sJYl+jYluRZiVT5dha+QyVJr2jX9qa28wEIZSSCe CX8l73JBwJA87TbBwKTEGb1oQxLZollO2oRjcUjRUWRmEAy6SMo2rMjeo7t8hUR/8x BWo1twgB1g3KA== Date: Sun, 4 Feb 2024 15:18:54 +0000 From: Jonathan Cameron To: Stephen Boyd Cc: Justin Stitt , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v5] iio: sx9324: avoid copying property strings Message-ID: <20240204151854.581fb780@jic23-huawei> In-Reply-To: References: <20240201-strncpy-drivers-iio-proximity-sx9324-c-v5-1-78dde23553bc@google.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 2 Feb 2024 15:38:03 -0600 Stephen Boyd wrote: > Quoting Justin Stitt (2024-02-01 10:55:03) > > We're doing some needless string copies when trying to assign the proper > > `prop` string. We can make `prop` a const char* and simply assign to > > string literals. > > > > For the case where a format string is used, let's extract the parsing > > logic out into sx9324_parse_phase_prop(). We no longer need to create > > copies or allocate new memory. > > > > sx9324_parse_phase_prop() will simply return the default def value if it > > fails. > > > > This also cleans up some deprecated strncpy() uses [1]. > > > > Furthermore, let's clean up this code further by removing some unused > > defines: > > | #define SX9324_PIN_DEF "semtech,ph0-pin" > > | #define SX9324_RESOLUTION_DEF "semtech,ph01-resolution" > > | #define SX9324_PROXRAW_DEF "semtech,ph01-proxraw-strength" > > > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] > > Link: https://github.com/KSPP/linux/issues/90 > > Cc: linux-hardening@vger.kernel.org > > Signed-off-by: Justin Stitt > > --- > > Reviewed-by: Stephen Boyd Applied