Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp230423rdb; Mon, 18 Sep 2023 13:16:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0Jhjcd0099FV47bsu8Vkjrz48bJ+e1lUMWoFuFmdY+awDC2rPuxm5NLjzB8wTiHRQLVk3 X-Received: by 2002:a05:6808:193:b0:3a7:215c:e34 with SMTP id w19-20020a056808019300b003a7215c0e34mr11768988oic.15.1695068175481; Mon, 18 Sep 2023 13:16:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695068175; cv=none; d=google.com; s=arc-20160816; b=DtZvdiFBOrV/54U/YQyOh74IHlXa2fa1NPP04jyK8vjEsFywOpapIXd2lhntBXlFk+ 7U3FC8gOUFdb8oS7Sf/dJQd8v4aC+SoUsX7QFA6pmC7yi3BMZe18ergOSaWguKei/AWl S7k19b20xkslEV784+0tWLih0hVQbJBoq0aQNqNQcZBrhN+vV0saQTMD2r75b4L1fwej Y5HzN7AmsR8q+HK09VKBNp4osB5OvATEmfrJzWnCRCt/F4NgsxLhjasml5H6QhSVFgu7 RxH94diYjyqUU8qIkHmvpVQpK5x6k8yddK0XnacxWKSQ1pA3KueQsYT9gSmt4WwOU3dQ /43A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=hEM+sX65EYtnCvEZrljBrs5RU7RITsBPnjrjq4pnkB8=; fh=LEIOttVCnaVNY8As4mEx9Zs/dg1idIy6t2iIxYbIW7k=; b=dvWiUAuADW8DOigaNuQON5TGUTQCeKbjhBe/RzcgbzaK2TGuZTJEIAr3EgiSJkA+/R X9c0GJIt+mzAjIvT1K0RBsoAvMth4JZC190DQHUKJ+jb4UF6804uc6WN84mzpZ0Ww6as b3oKELxMyKddcvRS+8JlGs9q4/WqthgkpLTv1kqXhJvIM4V7TCL/C+g2v0R2RSvB/H3D CowTn9mEepejIeLeK8oZWwYwHSZPA1cwuFs8T1rhdGEkXEj2B9qmxZ18prQtTSBfArSe 68tfprAhJdZiaNARpytN1OoZR9FlQgr2rb6Y6pSY8IB5yeZcFcukO9/JSgz3s1erJhk0 TJPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a4RwzZBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id a35-20020a631a63000000b00577f65baa3dsi8400934pgm.849.2023.09.18.13.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 13:16:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a4RwzZBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 0CF7F80295DE; Mon, 18 Sep 2023 09:21:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230021AbjIRQUq (ORCPT + 99 others); Mon, 18 Sep 2023 12:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230134AbjIRQUW (ORCPT ); Mon, 18 Sep 2023 12:20:22 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5549324995; Mon, 18 Sep 2023 09:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695053712; x=1726589712; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=D4xBX8r/3NDKqkwzlZDpf10xVrGyNATd0L8iCBQH01w=; b=a4RwzZBhhEizowUahWksPn+tOdzqTdy9XXOfufbnG5hPD0IxkYTBV8gb wvSxQn/x1dyPXEwDOsYLiXSwXafYcIdI3CiD2S0NoQWNFo/S7ZbcJR/Sv 6oMQVYvXtL4y1CAbwOd84d6oFc43V5kHKWoQEvt1GEaDw02BDnkPQmmNG JZK55j/UL3ztXSQ0gcOShcm/NzYq7XRukJdpNn2qms7w845yV/160VHVx jukZYmlG5afwqDTKRYFktAIp4WlIRUyiijibMQJ+N9ZTuTGWeB7H4fu89 zxaXMEewYCCgsno3/gSTSz4tT7CJNius1GE5JEhCkbB38VtZx4cjL435r A==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="379596552" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="379596552" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 08:38:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="816077146" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="816077146" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga004.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 08:38:22 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC0) (envelope-from ) id 1qiGKK-0000000Crwq-0SzJ; Mon, 18 Sep 2023 18:38:20 +0300 Date: Mon, 18 Sep 2023 18:38:19 +0300 From: Andy Shevchenko To: Rasmus Villemoes 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 Message-ID: References: <20230913092701.440959-1-andriy.shevchenko@linux.intel.com> <20230913092701.440959-2-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo 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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 09:21:00 -0700 (PDT) On Mon, Sep 18, 2023 at 04:48:40PM +0200, Rasmus Villemoes wrote: > On 13/09/2023 11.27, Andy Shevchenko wrote: > > - p = strchrnul(value, ';'); > > - *p = '\0'; > > + strreplace(value, ';', '\0'); > > So how do you know that the string contains at most one ';'? Same for > all the other replacements. If that's not guaranteed, this is not at all > equivalent. > > Or maybe the result is just used a normal string afterwards, and it > doesn't matter at all how the content after the first ';' has been mangled? > > It's certainly not obvious to me that this is correct, but of course I > know nothing about this code. If you read the comment and code slightly above you may get that this is not a problem at all. There are no side effects as the part after first occurrence of ; is not used and original string is NUL-terminated. -- With Best Regards, Andy Shevchenko