[PATCH v2 08/12] sysinfo: Add support for iterating string list

Marek Behún kabel at kernel.org
Fri Nov 5 12:24:34 CET 2021


On Thu, 4 Nov 2021 20:02:29 -0600
Simon Glass <sjg at chromium.org> wrote:

> Better to make iter a struct sysinfo_str_list_iter, I think and
> require the caller to declare it:
> 
> sysinfo_str_list_iter iter;
> char str[80]'
> 
> p = sysinfo_str_list_first(dev, i, &str, sizeof(str), &iter);
> ...
> 
> Do you need the iter?
> 
> If you want to support arbitratry length, I suppose that is OK?? But I
> don't like allocating memory unless it is needed.

Well if I am iterating through default environment variables
overwrites, they can be basically up to ENV_SIZE long. There may be
some long commands stored there.

Another solution would be to redesign sysinfo_get_str() and introduce
sysinfo_get_str_list() so that they won't fill a buffer given by user,
but instead have their own buffer in implementation and return const
char * pointer.

Marek


More information about the U-Boot mailing list