Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp239955rdb; Tue, 19 Dec 2023 15:28:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqpxERvqmHyaXpLw8zNKZ6jjxLfqvzEcna3puGpOzHUCW9DsHel/8fcm+AVVLsNbMLzsVK X-Received: by 2002:a05:620a:488d:b0:77e:fba3:a22a with SMTP id ea13-20020a05620a488d00b0077efba3a22amr23776044qkb.132.1703028481167; Tue, 19 Dec 2023 15:28:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703028481; cv=none; d=google.com; s=arc-20160816; b=GhyjdFas0v9mrY+0E6OV7R9v8GyeURFaIsjyfs00Hgm/BjOgBcxk71nbhXeFns+Fb0 fXR36rYgpTFd3M3fcHYfVTlhbSCpyqsuLtkb+/ttfNkts4l3ck7j3aaA6LU8jB/qABrl 4eX4t8eF2niyTsmQreUej+kByQkWSIrmmVSim/3WkYUHjlOLkTSf01Yqjxk86VXSxZXN h1VWXajRnzKiZV4d2TNn/qkcOIrvZWVY6C7LLVEq8zBws+d0bYPJ2Od9ya6JGoh3T1xO 6tU+T8DrMnIGERhbfu/Ukl1pCB7VhBIsENEc3/mJEE0KzBjZCfYTCKyNc6iKBYobO4vF pKNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:user-agent:from:references :in-reply-to:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:dkim-signature; bh=wib2+T/twwwN/3BXe0yj7pCHfEZ8cIQ5+MZvHiZViLk=; fh=NUS17hlIOlMkHsf63rhWjPR2XqZktva1ib6jdu0mFqM=; b=cx1dxVN71FCx1/m68bafYw4K3VfoimyQ1oztOi0brY4udVvOkhrJrZKMEMrUi349ta svwMFLoLh8yCFQ/29uC8/SlD7bWRQtCsVvv2EKpbkqjziK2wP7USgD/WfsaDYSapJVM/ M5w51dvNDd6z+8zwpGPS+yaOzUNZl6ESiNbmq2L7gxgkqjlzIL1kuFt0+rqdkX7e+TUb 41AWidnUqg1pKGOM67SG6XvaRSuTHy8yExx6TNLQKoSy9TBwlPhyFprarC2nI1sjSjmx gG1L0ohgTgpxOZ9LttPUkgrQOaQzWen3B61DAyM0d6HLG9jHdaN6XvGlwcq+n/KoxkoB fN2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iXgzLxqi; spf=pass (google.com: domain of linux-kernel+bounces-6098-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6098-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id l5-20020a05620a28c500b0077db39f2e53si28542221qkp.628.2023.12.19.15.28.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 15:28:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6098-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iXgzLxqi; spf=pass (google.com: domain of linux-kernel+bounces-6098-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6098-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D712A1C24EB4 for ; Tue, 19 Dec 2023 23:28:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C4443DB80; Tue, 19 Dec 2023 23:27:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="iXgzLxqi" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 7F7AA40BF6 for ; Tue, 19 Dec 2023 23:27:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-50e239c49d0so5076099e87.2 for ; Tue, 19 Dec 2023 15:27:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1703028467; x=1703633267; darn=vger.kernel.org; h=cc:to:subject:message-id:date:user-agent:from:references :in-reply-to:mime-version:from:to:cc:subject:date:message-id :reply-to; bh=wib2+T/twwwN/3BXe0yj7pCHfEZ8cIQ5+MZvHiZViLk=; b=iXgzLxqiePhff7jKystdfcjwNzwYmsPy/Pk/gYPA27zSG9G2ScITsc+zl4iJfsr/8j iF991C6eO9svijDDeqIYGaEyseTUoamip0QWjBcn+D5dOee0YIc4WGqvxxSqXpI+Hxby jRYRV1JyUe9dV+xC8e5DrR/uekUVQmPriVjQg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703028467; x=1703633267; h=cc:to:subject:message-id:date:user-agent:from:references :in-reply-to:mime-version:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wib2+T/twwwN/3BXe0yj7pCHfEZ8cIQ5+MZvHiZViLk=; b=Jk+lyMQ0QJw/IIarADm/WiwIsIH1a3tQaaL55Ajj4fHeMlnrXhIe/AhoUl1jhXi++Y zJhmV/+PnR8HvOXlKBweHRYDxBNOSBYOL+k63uoXM5ydWza2T7/CGzC+VeqSe+obr1IH TcGawIcTP+X2qwLQgoT3ac3QT2oEiaVdicD9wHb53Kw+hxfPF5cuxjwKr3leoFWqAVi0 Ouqq2fOxAo69oVzkBVeGY7ZieOojGFBubYL1t6G42O1F88rtv5Qkz5uRAG1yGDKkcAJ8 Vz1fXaIbryUMVA7soOFwxW1MlEOCYuwSiLVUwt0pIFBuoCkEOBG0laPBj/tKEICnB9Qu IE5g== X-Gm-Message-State: AOJu0Yx7gfFEsJiFyjSoLHpKg0KRalsOnAPo+zfJwaUJoiYQOiXw9ejy 9d0PNoxGpc1gLUUtN/DjOgkb8+zJpSCgXZCXSlUJaw== X-Received: by 2002:a05:6512:102c:b0:50c:e98:1ded with SMTP id r12-20020a056512102c00b0050c0e981dedmr7072856lfr.132.1703028467520; Tue, 19 Dec 2023 15:27:47 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Tue, 19 Dec 2023 15:27:47 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20231219-strncpy-drivers-iio-proximity-sx9324-c-v4-1-d49ed29ee952@google.com> References: <20231219-strncpy-drivers-iio-proximity-sx9324-c-v4-1-d49ed29ee952@google.com> From: Stephen Boyd User-Agent: alot/0.10 Date: Tue, 19 Dec 2023 15:27:46 -0800 Message-ID: Subject: Re: [PATCH v4] iio: sx9324: avoid copying property strings To: Jonathan Cameron , Justin Stitt , Lars-Peter Clausen Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Quoting Justin Stitt (2023-12-19 13:34:15) > 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