Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4871044rdb; Fri, 15 Sep 2023 15:15:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqu6UeLY9ZqfeUtS+OahKCJGAm/Z6MaLaQvzI6LIFc9lnGzm9Z4j513ria1SUZM3CBeXmv X-Received: by 2002:a05:6808:3ce:b0:3a7:459d:61bf with SMTP id o14-20020a05680803ce00b003a7459d61bfmr3046487oie.0.1694816108231; Fri, 15 Sep 2023 15:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694816108; cv=none; d=google.com; s=arc-20160816; b=0aT2OGqBTIWc3Py63CYlCBZQhAS1w1yL8vZ2Q35L9rhvauyjIR4tPNqft4fwiER6BO Xl11vI61PR66Em9rX1vKiZRn+A0K3+bPDPvZBn68c5FfGrV6ZCead6lpHJ0DGst8g33j Fm9TAiPczKBz25A8ZproHICyJbvOevMCjPYAITtaBVMtQo5KksUZgEv2danAnmfkWQ1V 9m8xpllHoNJ5hxsOnL+sNR6A/Xc+uLHW2c2PSuP1kjZMi1/bsFERT5XB6ZnelCr2yMT2 G7lPxeyWJVJsdySMMEEAfw+PHq0p9zCBXikNyoXd5RtL9caGSICcuSs5BJKWwTTQKXNb qwGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=tKKcN1GzLEIK1oW53XHaAaN7ZUlG47ZNExkp1X/LzD8=; fh=yMmVO8m8+AltKte9k8XC1t5w9Miw3AUlLpm3MwG/dZs=; b=Ao92YlZ9JkHw2CImCkVqD+cWCmwCI3EA9mUT98u91NOBRwFPLtqcbOmawfluOE8OMK njRImZtuQWIrOBQZPT/8LnmBb+CxYXq0SH4WSeFih+fC25tRVW/o1Ov4FWxAi67YiaRS TY/uVELxydFPlMfDrtxKOblapMeAReQWeMgTUDeXqFSQVrRjLwPMMyhZuveCL1a3sme4 cCEtgQoNRRTcKSZww006d7H9KLeM6Y7y3mBrj3rUKJq/cqE+HZCD62//kWSrxEDs/eUM zxdE4i3nL9NCWHfp5GOvS+Y8sA66bnAsq+MXCgdJSWQL9k/Crh0Jp1+GCyP9ghd9q3yk aXNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AfhE7lND; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id ca7-20020a056a00418700b0068a59c09978si3999690pfb.189.2023.09.15.15.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 15:15:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AfhE7lND; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 47492837BE7C; Fri, 15 Sep 2023 07:58:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232499AbjIOO6U (ORCPT + 99 others); Fri, 15 Sep 2023 10:58:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbjIOO6U (ORCPT ); Fri, 15 Sep 2023 10:58:20 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5305C1BE6; Fri, 15 Sep 2023 07:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694789895; x=1726325895; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=2z/dkyd5Stib+6LmzNwLg0OjKOGPr/1NjgAbwJkJ+88=; b=AfhE7lNDdF3FlEoqq0xiNx9/fJURdKFkr8i3Rw846Dih00TedPbpqVMz dM6QLshuOVCvrYPLA/UmIFcRHydkMTnysFH4N/70OYinddO4wzWNHqGBv idVF89RQtrhCoPf9fLfqyopXAr7Yqg+ZLLToQzD0My+qW8oiyMjAfdV7n dYPgYA51GGqvFut014hhXfEv6TFinobMtIih653cmXY9Sj5mnpGDEmmBh IH3Z7S0D6fUaBkU/TZcdw+eqr4f33chkdIozWpkN3q307riZfbQjHjE8N 3O6Dd6HBvPzN/V/ROKEVfmA9zrN7DdyWqgMXDOr2niwdDc1gaKM4HbgDY g==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="410204205" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="410204205" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 07:58:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="1075826203" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="1075826203" Received: from srdoo-mobl1.ger.corp.intel.com ([10.252.38.99]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 07:58:01 -0700 Date: Fri, 15 Sep 2023 17:57:59 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Andy Shevchenko cc: Hans de Goede , Mark Pearson , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Pearson , Mark Gross Subject: Re: [PATCH v1 2/2] platform/x86: think-lmi: Use strreplace() to replace a character by nul In-Reply-To: <20230913092701.440959-2-andriy.shevchenko@linux.intel.com> Message-ID: <227454d0-e33a-179c-b4df-1f486136ca6@linux.intel.com> References: <20230913092701.440959-1-andriy.shevchenko@linux.intel.com> <20230913092701.440959-2-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-2140016275-1694789883=:2347" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 07:58:30 -0700 (PDT) This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-2140016275-1694789883=:2347 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8BIT On Wed, 13 Sep 2023, Andy Shevchenko wrote: > We can replace > p = strchrnul(str, '$OLD'); > *p = '\0'; > with > strreplace(str, '$OLD', '\0'); > that does the compatible modification without a need of the temporary variable. > > Signed-off-by: Andy Shevchenko > --- > drivers/platform/x86/think-lmi.c | 19 ++++--------------- > 1 file changed, 4 insertions(+), 15 deletions(-) > > diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c > index 94a3c7a74bc4..2f20fafe7f55 100644 > --- a/drivers/platform/x86/think-lmi.c > +++ b/drivers/platform/x86/think-lmi.c > @@ -198,14 +198,6 @@ static struct think_lmi tlmi_priv; > static struct class *fw_attr_class; > static DEFINE_MUTEX(tlmi_mutex); > > -/* ------ Utility functions ------------*/ > -/* Strip out CR if one is present */ > -static void strip_cr(char *str) > -{ > - char *p = strchrnul(str, '\n'); > - *p = '\0'; > -} > - > /* Convert BIOS WMI error string to suitable error code */ > static int tlmi_errstr_to_err(const char *errstr) > { > @@ -411,7 +403,7 @@ static ssize_t current_password_store(struct kobject *kobj, > > strscpy(setting->password, buf, setting->maxlen); > /* Strip out CR if one is present, setting password won't work if it is present */ > - strip_cr(setting->password); > + strreplace(setting->password, '\n', '\0'); > return count; > } > > @@ -921,7 +913,7 @@ static ssize_t display_name_show(struct kobject *kobj, struct kobj_attribute *at > static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) > { > struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); > - char *item, *value, *p; > + char *item, *value; > int ret; > > ret = tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID); > @@ -934,8 +926,7 @@ static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *a > ret = -EINVAL; > else { > /* On Workstations remove the Options part after the value */ > - p = strchrnul(value, ';'); > - *p = '\0'; > + strreplace(value, ';', '\0'); > ret = sysfs_emit(buf, "%s\n", value + 1); > } > kfree(item); > @@ -1418,7 +1409,6 @@ static int tlmi_analyze(void) > for (i = 0; i < TLMI_SETTINGS_COUNT; ++i) { > struct tlmi_attr_setting *setting; > char *item = NULL; > - char *p; > > tlmi_priv.setting[i] = NULL; > ret = tlmi_setting(i, &item, LENOVO_BIOS_SETTING_GUID); > @@ -1435,8 +1425,7 @@ static int tlmi_analyze(void) > strreplace(item, '/', '\\'); > > /* Remove the value part */ > - p = strchrnul(item, ','); > - *p = '\0'; > + strreplace(item, ',', '\0'); > > /* Create a setting entry */ > setting = kzalloc(sizeof(*setting), GFP_KERNEL); > Reviewed-by: Ilpo J?rvinen -- i. --8323329-2140016275-1694789883=:2347--