[PATCH] Fix strv_addn(), add strv_split()
Martin Schwenke
martin at meltin.net
Mon Feb 29 11:30:27 UTC 2016
On Mon, 29 Feb 2016 10:41:48 +0100, Volker Lendecke
<Volker.Lendecke at SerNet.DE> wrote:
> On Mon, Feb 29, 2016 at 08:14:02PM +1100, Martin Schwenke wrote:
> > On Mon, 29 Feb 2016 15:32:49 +1100, Martin Schwenke <martin at meltin.net>
> > wrote:
> >
> > > 2 patches attached:
> > >
> > > 1. Fix strv_addn()
> > >
> > > Well, this is embarrassing! I added strv_add() last week but it
> > > doesn't do what it was meant to and actually produces an invalid
> > > strv. :-(
> > >
> > > This fixes it and adds some tests for it.
> > >
> > > Given that the patch goes close to a revert, I'm happy with the
> > > alternative of reverting and adding this anew... but it seems like
> > > more hassle.
> > >
> > > 2. Add strv_split() in new file strv_util.[hc] + tests
> > >
> > > I mentioned this to Volker and he wants to keep strv.[hc] small, so
> > > suggested that a layer on top could go in an extra file, so here it
> > > is.
> > >
> > > Clearly (2) depends on (1), since it uses strv_addn().
> >
> > Volker sent me an untested but better alternative implementation of
> > strv_addn(). I keep forgetting the magic where you can use a
> > parameter in the size of a local array declaration... even though
> > Amitay mentioned that magic today. :-)
> >
> > So, attached are 4 patches:
> >
> > 1. Revert original add of strv_addn()
> >
> > 2. Add strv_addn()
> >
> > I've made Volker the author and added his sign-off and my review.
> > Hopefully this isn't too cheeky. ;-)
> >
> > 3. Add strv_addn() tests
>
> Pushed those three.
Thanks.
> > 4. Add strv_split() + tests
>
> Nit-picking a bit: Do we need to check for s==NULL in every while
> iteration?
Doesn't the compiler have an optimiser so that I can write garbage
code? ;-)
New patch attached with that change...
peace & happiness,
martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lib-util-Add-strv_util.-ch-containing-new-function-s.patch
Type: text/x-patch
Size: 9477 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20160229/ce7fe410/0001-lib-util-Add-strv_util.-ch-containing-new-function-s.bin>
More information about the samba-technical
mailing list