[systemd-devel] [PATCH] util: allow strappenda to take any number of args
Dave Reisner
d at falconindy.com
Wed Aug 13 17:43:58 PDT 2014
On Thu, Aug 14, 2014 at 01:28:15AM +0200, Lennart Poettering wrote:
> On Wed, 13.08.14 16:35, Dave Reisner (dreisner at archlinux.org) wrote:
>
> Looks good. The code is certainly not any more complicated than the
> current strapenda3(), so it sounds like something to apply.
>
> > /* If the passed init is actually the same as the
> > * systemd binary, then let's suppress it. */
> > diff --git a/src/test/test-util.c b/src/test/test-util.c
> > index 16f89b4..8776899 100644
> > --- a/src/test/test-util.c
> > +++ b/src/test/test-util.c
> > @@ -907,6 +907,12 @@ static void test_strshorten(void) {
> > assert_se(strlen(strshorten(s, 0)) == 0);
> > }
> >
> > +static void test_strappenda(void) {
> > + assert_se(streq(strappenda("", "foo", "bar"), "foobar"));
> > + assert_se(streq(strappenda("foo", "bar", "baz"), "foobarbaz"));
> > + assert_se(streq(strappenda("foo", "", "bar", "baz"), "foobarbaz"));
> > +}
>
> it's not portable to avoid alloca() when invoking a function (which the
> strlen() in streq() is). This is documented in the alloca(3) man page,
> see section "BUGS".
Ah, thanks!
> Can you change the test to first place the result of strappenda() in a
> variable, and then pass that on to streq()?
>
> Please commit then!
Fixed up and pushed, thanks for the quick review!
d
More information about the systemd-devel
mailing list