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 67807C433F5 for ; Sun, 31 Oct 2021 15:27:24 +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 6935560E8C for ; Sun, 31 Oct 2021 15:27:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6935560E8C 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 7D54582BC0; Sun, 31 Oct 2021 16:27:21 +0100 (CET) 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="T9CQousX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 176B381F0B; Sun, 31 Oct 2021 16:27:19 +0100 (CET) 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 7526481F0B for ; Sun, 31 Oct 2021 16:27:15 +0100 (CET) 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 2B76860E8C; Sun, 31 Oct 2021 15:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635694032; bh=MYu/9TNh+cYxdxZBM1DgeowSrWH64g50eZdzsff7O10=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=T9CQousXY0xUwBnFG8GTOY4YWkUFmIaIjV28tz9054sSPl40tpAlG+M1VkPj8WGHi INXJL4F/kqpLZFfSiQZ6h5HfuIL/+VvSEI8qhOgWs8lzwT9XBs31CS1d280YpdZ4cb y3YKMvbQCE+cus56E6ElIHS3L40fieTM2UsNV5nYmUB83TbVeJlPYoPhl98rsDs0JY pgVBz8RFEiZvy0ZM8PQ4seFKB0360IMUUxirzxSCsgmc9sl2LGte8kUbDN3FYwweWf NXDYSdpCiLzwwv97B7qLqK8qfr7XiNEIG4TU366qVlZ2ecsOVeY0bBkZuz2+rnJGTB e+OQBY4Lye2ug== Date: Sun, 31 Oct 2021 16:27:07 +0100 From: Marek =?UTF-8?B?QmVow7pu?= To: Simon Glass Cc: Pali =?UTF-8?B?Um9ow6Fy?= , Stefan Roese , u-boot@lists.denx.de, Marek =?UTF-8?B?QmVow7pu?= Subject: Re: [PATCH 2/5] env: Fix env_get() when returning empty string using env_get_f() Message-ID: <20211031162707.1065cab3@thinkpad> In-Reply-To: References: <20211028032810.18146-1-kabel@kernel.org> <20211028032810.18146-3-kabel@kernel.org> <20211029090306.srbu7jwiyiyh5lz7@pali> 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=UTF-8 Content-Transfer-Encoding: quoted-printable 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 On Sun, 31 Oct 2021 07:07:47 -0600 Simon Glass wrote: > Hi, >=20 > On Fri, 29 Oct 2021 at 03:03, Pali Roh=C3=A1r wrote: > > > > On Thursday 28 October 2021 21:17:38 Simon Glass wrote: =20 > > > Hi Marek, > > > > > > On Wed, 27 Oct 2021 at 21:28, Marek Beh=C3=BAn wro= te: =20 > > > > > > > > From: Marek Beh=C3=BAn > > > > > > > > The env_get_f() function returns -1 on failure. Returning 0 means t= hat > > > > the variable exists, and is empty string. > > > > > > > > Signed-off-by: Marek Beh=C3=BAn > > > > --- > > > > env/common.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) =20 > > > > > > Reviewed-by: Simon Glass > > > > > > But it isn't normally possible to set an env var to an empty string. > > > How does this happen? =20 > > > > IIRC you can set variable to empty string via e.g.: > > > > setenv abc '' =20 >=20 > Yes that works and I now see you are all right. In fact the command > handling for 'env set' does not use env_set(). >=20 > It seems a bit inconsistent to me. Since a deleted variable is > considered empty, do we need to support empty vars? Depends on what you mean by "support". I think that if the user does setenv xyz "" it shouldn't be an error. Whether it deletes the variable or not is something different (although I would make it so that the variable is not deleted...). But env_get_f("xyz") shouldn't return -1 in this case, as that indicates an error. Marek