[U-Boot] [u-boot-release] [PATCH 6/7] getenv_f() env variable exist w/o needing a buffer

Timur Tabi timur at freescale.com
Mon Jan 7 18:46:06 CET 2013


York Sun wrote:
> From: James Yang <James.Yang at freescale.com>
> 
> 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 <James.Yang at freescale.com>

Acked-by: Timur Tabi <timur at freescale.com>

-- 
Timur Tabi
Linux kernel developer at Freescale



More information about the U-Boot mailing list