From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 719A7C433EF for ; Fri, 15 Oct 2021 13:20:55 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 909D660C49 for ; Fri, 15 Oct 2021 13:20:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 909D660C49 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 43BA583873; Fri, 15 Oct 2021 15:20:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="knR418f3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6C42883896; Fri, 15 Oct 2021 15:20:50 +0200 (CEST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 69D1283846 for ; Fri, 15 Oct 2021 15:20:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kabel@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id D551361151; Fri, 15 Oct 2021 13:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634304045; bh=WKwAQPkBq7l/rpt3pQHwntiQd8N8Hujpzg+A8DxVwt4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=knR418f3XI8l5yqgrl4vxKbLV05yPIOfN1j2eDXYHvQ4d0/nXGZeXyN7W7AtZaCrf cUCVvWkVwIuSaDX5Z1eHTTFa4cj5PFk5pKh9l9sU+pG4+NS5CTKSy7RszfCrCtAzTu m82tJzjbEfYSsaS11baSfgZFKKb/4eoAtDvH2ZhcHYVdHX3/gYUf/u4W/iI0rSdZQo JC+JiIwkUgo61MbgAELPrnf/kUKxyzdw3hjqhfUePSInEMo9riJkAA5ArhLWp+I+iJ +3Xhnv2HGGg+uG5j0TZ60nNCxElyAcAm/0r7OFksDuDEthB0M/RA9H3/5d+Ah30Oy3 ur8oXTj4vrzSA== Date: Fri, 15 Oct 2021 15:20:42 +0200 From: Marek =?UTF-8?B?QmVow7pu?= To: Simon Glass Cc: Tom Rini , U-Boot Mailing List , Marek =?UTF-8?B?QmVow7pu?= Subject: Re: [PATCH v2 09/13] env: Use string pointer instead of indexes in env_get_f() Message-ID: <20211015152042.7f00438d@dellmb> In-Reply-To: References: <20211013154557.28479-1-kabel@kernel.org> <20211013154557.28479-10-kabel@kernel.org> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Simon, On Thu, 14 Oct 2021 18:40:02 -0600 Simon Glass wrote: > > -static int env_match(const char *env, const char *s1, int i2) > > +static const char *matching_name_get_value(const char *p, const > > char *name) > > OK so this is the function where I would like a nice comment, please. Now that I look at it, I notice that it also works for cases when name is "abc=def" (it matches just "abc"). This was the purpose of env_match() before, but env_get_f() does not use it that way, and this functionality can now be removed. This would simplify the code to something like len = strlen(name); if (p[len] == '=' && !strncmp(p, name, len)) return &p[len + 1]; return NULL; And this is simple enough to be inlined into env_get_f(). I will refactor this and send v3. Marek