[Rpm-maint] [PATCH] Check for undefined macros
Dmitry V. Levin
ldv at altlinux.org
Wed Feb 6 03:24:57 UTC 2013
On Wed, Feb 06, 2013 at 02:55:33AM +0000, Alexey Tourbin wrote:
> On Wed, Feb 06, 2013 at 05:48:58AM +0400, Dmitry V. Levin wrote:
> > On Sun, Jan 27, 2013 at 05:27:09AM +0000, Alexey Tourbin wrote:
> > [...]
> > > --- a/build/pack.c
> > > +++ b/build/pack.c
> > > @@ -22,6 +22,7 @@
> > > #include "build/rpmbuild_misc.h"
> > >
> > > #include "debug.h"
> > > +#include <libgen.h>
> > >
> > > typedef struct cpioSourceArchive_s {
> > > rpm_loff_t cpioArchiveSize;
> > > @@ -91,12 +92,14 @@ static rpmRC addFileToTag(rpmSpec spec, const char * file,
> > > }
> > > }
> > >
> > > + int lineNum = 0;
> > > while (fgets(buf, sizeof(buf), f)) {
> > > - if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
> > > - rpmlog(RPMLOG_ERR, _("%s: line: %s\n"), fn, buf);
> > > + char *exp = rpmExpandMacros(spec->macros, buf,
> > > + basename(fn), ++lineNum, NULL, NULL);
> > > + if (exp == NULL)
> > > goto exit;
> > > - }
> > > - appendStringBuf(sb, buf);
> > > + appendStringBuf(sb, exp);
> > > + free(exp);
> > > }
> > > headerPutString(h, tag, getStringBuf(sb));
> > > rc = RPMRC_OK;
> >
> > There is no need to include <libgen.h>, just otherwise, since configure.ac
> > uses AC_USE_SYSTEM_EXTENSIONS, you should avoid including <libgen.h> to
> > get the GNU version of basename().
>
> Some files already include <libgen.h> for XPG basename(3) and dirname(3),
> and some not.
All it proves is that the code base you are working with is inconsistent
in this aspect. My recommendation is to avoid making the code less
consistent than it is.
There is no reason to include <libgen.h> unless you need its dirname()
prototype. This command
$ comm -3 <(git grep -Fl libgen.h |sort) <(git grep -l '\<dirname *(' -- $(find * -name \*.c) |sort)
build/files.c
lib/fprint.c
shows that build/files.c and lib/fprint.c shouldn't include <libgen.h>.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20130206/12dee206/attachment.asc>
More information about the Rpm-maint
mailing list