From mboxrd@z Thu Jan 1 00:00:00 1970 From: Timur Tabi Date: Mon, 7 Jan 2013 11:46:06 -0600 Subject: [U-Boot] [u-boot-release] [PATCH 6/7] getenv_f() env variable exist w/o needing a buffer In-Reply-To: <1357323245-12455-6-git-send-email-yorksun@freescale.com> References: <1357323245-12455-1-git-send-email-yorksun@freescale.com> <1357323245-12455-6-git-send-email-yorksun@freescale.com> Message-ID: <50EB09DE.9020104@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de York Sun wrote: > From: James Yang > > getenv_f() searches the environment for a variable name and copies the > value of the variable to a buffer pointed to by one of the function's > parameters. However, this means that the buffer needs to exist and > needs to be of sufficient length (passed as another parameter to > getenv_f()) to hold the requested variable's value, even if all that is > desired is the mere detection of the existence of the variable itself. > > This patch removes the requirement that the buffer needs to exist. If > the pointer to the buffer is set to NULL and the requested variable is > found, getenv_f() returns 1, else it returns -1. The buffer length > parameter is ignored if the pointer is set to NULL. The original > functionality of getenv_f() is retained (return number of bytes copied > if variable is found, -1 if not), other than being able to copy the > variable's value to the address 0. > > Signed-off-by: James Yang Acked-by: Timur Tabi -- Timur Tabi Linux kernel developer at Freescale