[systemd-devel] typo? path-util: unify code for detecting OS trees

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Wed Apr 17 04:52:08 PDT 2013


On Wed, Apr 17, 2013 at 09:33:35AM +0200, Peeters Simon wrote:
> while reading random patches in cgit I saw
> (in commit 6606089752df90f3eeb4924af109046f1c73554c)
> 
> ...
> > diff --git a/src/shared/util.h b/src/shared/util.h
> > index 3aac165..cfb5493 100644
> > --- a/src/shared/util.h
> > +++ b/src/shared/util.h
> > @@ -684,3 +684,15 @@ int unlink_noerrno(const char *path);
> > _new_ = alloca(_len_); \
> > (void *) memset(_new_, 0, _len_); \
> > })
> > +
> > +#define strappenda(a, b) \
> > + ({ \
> > + const char *_a_ = (a), *_b_ = (b); \
> > + char *_c_; \
> > + size_t _x_, _y_; \
> > + _x_ = strlen(_a_); \
> > + _y_ = strlen(_b_); \
> > + _c_ = alloca(_x_ + _y_ + 1); \
> > + strcpy(stpcpy(_c_, _a_), _b_); \
stpcpy returns the end of the copy, and then strcpy appends
to this end.

Zbyszek

> shouldn't this be more like:
> strcat(strcpy(_c_, _a_), _b_);
> 
> > + _c_; \
> > + })


More information about the systemd-devel mailing list