[U-Boot] [PATCH 5/5] fit: Introduce methods for applying overlays on fit-load
Lothar Waßmann
LW at KARO-electronics.de
Wed Jul 5 06:32:20 UTC 2017
Hi,
On Wed, 5 Jul 2017 00:19:28 +0200 stefan.bruens at rwth-aachen.de wrote:
> On Dienstag, 4. Juli 2017 19:05:25 CEST Pantelis Antoniou wrote:
> > Hi Marek,
> >
> > On Sat, 2017-07-01 at 16:11 +0200, Marek Vasut wrote:
> > > On 06/30/2017 06:23 PM, Pantelis Antoniou wrote:
> > > > Introduce an overlay based method for constructing a base DT blob
> > > > to pass to the kernel.
> > > >
> > > > Both canned and runtime feature selection is supported.
> > > >
> > > > Signed-off-by: Pantelis Antoniou <pantelis.antoniou at konsulko.com>
> > >
> > > [...]
> > >
> > > > @@ -1475,29 +1482,58 @@ int fit_conf_get_node(const void *fit, const
> > > > char *conf_uname)> >
> > > > debug("Found default configuration: '%s'\n", conf_uname);
> > > >
> > > > }
> > > >
> > > > + s = strchr(conf_uname, '#');
> > > > + if (s) {
> > > > + len = s - conf_uname;
> > > > + conf_uname_copy = malloc(len + 1);
> > > > + if (!conf_uname_copy) {
> > > > + debug("Can't allocate uname copy: '%s'\n",
> > > > + conf_uname);
> > > > + return -ENOMEM;
> > > > + }
> > > > + memcpy(conf_uname_copy, conf_uname, len);
> > >
> > > Is that like strdup() here ?
> >
> > No. The space allocated is not the full string, just the span until the
> > next #.
>
> You could use strndup() to copy only the first n characters.
>
or strsep() to tokenize (a copy of) the original string.
IMO using strdup() and strsep() makes the intent of this function
clearer, than the current code.
Lothar Waßmann
More information about the U-Boot
mailing list