[PATCH v2 06/12] sysinfo: Add get_str_list() method

Simon Glass sjg at chromium.org
Fri Nov 5 17:12:14 CET 2021


Hi Marek,

On Fri, 5 Nov 2021 at 05:20, Marek Behún <kabel at kernel.org> wrote:
>
> On Thu, 4 Nov 2021 20:02:27 -0600
> Simon Glass <sjg at chromium.org> wrote:
>
> > On Wed, 3 Nov 2021 at 17:23, Marek Behún <kabel at kernel.org> wrote:
> > >
> > > From: Marek Behún <marek.behun at nic.cz>
> > >
> > > Add get_str_list() method to sysinfo operations.
> > >
> > > The get_str_list() method is similar to get_str(), but receives one
> > > additional argument, @idx, and fills in the @idx-th string from a given
> > > list.
> > >
> > > Add sandbox implementation together with a unittest.
> > >
> > > Signed-off-by: Marek Behún <marek.behun at nic.cz>
> > > ---
> > >  drivers/sysinfo/sandbox.c        | 15 +++++++++++
> > >  drivers/sysinfo/sysinfo-uclass.c | 15 +++++++++++
> > >  include/sysinfo.h                | 44 ++++++++++++++++++++++++++++++++
> > >  test/dm/sysinfo.c                | 13 ++++++++++
> > >  4 files changed, 87 insertions(+)
> > >
> >
> > Reviewed-by: Simon Glass <sjg at chromium.org>
> >
> > Except I think it should return -NOSPC if the buffer is too small.
>
> No because then you don't know how large buffer you actually need and
> have to guess (or grow by a factor of two until it fits).
>
> This way you can call with size=0, get the length, allocate buffer and
> call again.

OK, I completely missed that. Can you mention this approach in the comments?

"Actual length of the string" - does that mean the length that would
have been returned if there were enough space? If so, please make that
clear.

Regards,
Simon

>
> Marek


More information about the U-Boot mailing list