[systemd-devel] [PATCH 3/3] core: remove unneeded <libgen.h> include
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Wed Feb 11 09:27:30 PST 2015
On Wed, Feb 11, 2015 at 06:26:41PM +0100, Lennart Poettering wrote:
> On Wed, 11.02.15 18:21, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:
>
> > On Wed, Feb 11, 2015 at 06:18:54PM +0100, Lennart Poettering wrote:
> > > On Wed, 11.02.15 18:10, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:
> > >
> > > > On Wed, Feb 11, 2015 at 06:05:13PM +0100, Lennart Poettering wrote:
> > > > > On Mon, 09.02.15 21:41, Cristian Rodríguez (crrodriguez at opensuse.org) wrote:
> > > > >
> > > > > > execute.c only uses basename (the GNU version in <string.h>)
> > > > >
> > > > > Is this right even?
> > > > >
> > > > > This was added by Zbigniew in 2b6bf07dd23bb467099d213c97b3875c5e453491:
> > > > >
> > > > > "Get rid of our reimplementation of basename
> > > > >
> > > > > The only problem is that libgen.h #defines basename to point to
> > > > > it's own broken implementation instead of the GNU one. This can be
> > > > > fixed by #undefining basename."
> > > > >
> > > > >
> > > > > So, what's this about?
> > > > >
> > > > > Somehow, given how stupid basename is defined, I am tempted to
> > > > > introduce a call for this again, that is not stupid, and works for all
> > > > > cases without ambiguities.
> > > > >
> > > > > Anyway, Zbigniew, could you comment on this, please?
> > > > I think the patch is fine. As long as every libgen.h include is followed
> > > > by #undef basename, things are OK.
> > >
> > > Can you elaborate on the background of this? Why the #undef precisely?
> > > The man page says nothing about this?
> > libgen.h contains
> >
> > extern char *__xpg_basename (char *__path) __THROW;
> > #define basename __xpg_basename
> >
> > And __xpg_basename is the borked implementation. #undef basename means that
> > we use the GNU version instead.
>
> So, hmm, so if I got this right:
>
> a) The good basame() is in strings.h
> b) The bad basename() is in libgen.h
> c) The only other call in libgen.h is dirname()
>
> Which means, that we only ever need to include libgen.h when we need
> dirname(), and that avery single including of libgen.sh should be
> matched with an "#undef basename"?
Yes and yes.
Zbyszek
More information about the systemd-devel
mailing list