Skip to content

Commit

Permalink
Eliminate debug junk from the API
Browse files Browse the repository at this point in the history
- add some helper macros to accomplish the same, easy to enable / disable
  as needed
  • Loading branch information
pmatilai committed Dec 4, 2007
1 parent 422fa0d commit dbdbe80
Show file tree
Hide file tree
Showing 26 changed files with 121 additions and 215 deletions.
15 changes: 9 additions & 6 deletions build/pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,13 +684,14 @@ int packageBinaries(rpmSpec spec)
memset(csa, 0, sizeof(*csa));
csa->cpioArchiveSize = 0;
/* LCL: function typedefs */
csa->cpioFdIn = fdNew("init (packageBinaries)");
csa->cpioList = rpmfiLink(pkg->cpioList, "packageBinaries");
csa->cpioFdIn = fdNew(RPMDBG_M("init (packageBinaries)"));
csa->cpioList = rpmfiLink(pkg->cpioList, RPMDBG_M("packageBinaries"));

rc = writeRPM(&pkg->header, NULL, fn, csa, spec->passPhrase, NULL);

csa->cpioList = rpmfiFree(csa->cpioList);
csa->cpioFdIn = fdFree(csa->cpioFdIn, "init (packageBinaries)");
csa->cpioFdIn = fdFree(csa->cpioFdIn,
RPMDBG_M("init (packageBinaries)"));
fn = _free(fn);
if (rc)
return rc;
Expand Down Expand Up @@ -723,15 +724,17 @@ int packageSources(rpmSpec spec)
memset(csa, 0, sizeof(*csa));
csa->cpioArchiveSize = 0;
/* LCL: function typedefs */
csa->cpioFdIn = fdNew("init (packageSources)");
csa->cpioList = rpmfiLink(spec->sourceCpioList, "packageSources");
csa->cpioFdIn = fdNew(RPMDBG_M("init (packageSources)"));
csa->cpioList = rpmfiLink(spec->sourceCpioList,
RPMDBG_M("packageSources"));

spec->sourcePkgId = NULL;
rc = writeRPM(&spec->sourceHeader, &spec->sourcePkgId, fn,
csa, spec->passPhrase, &(spec->cookie));

csa->cpioList = rpmfiFree(csa->cpioList);
csa->cpioFdIn = fdFree(csa->cpioFdIn, "init (packageSources)");
csa->cpioFdIn = fdFree(csa->cpioFdIn,
RPMDBG_M("init (packageSources)"));
fn = _free(fn);
}
return rc;
Expand Down
9 changes: 9 additions & 0 deletions debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@
#include <dmalloc.h>
#endif

#define RPMDBG_TOSTR(a) RPMDBG_TOSTR_ARG(a)
#define RPMDBG_TOSTR_ARG(a) #a

#define RPMDBG() "at: " __FILE__ ":" RPMDBG_TOSTR (__LINE__)
#define RPMDBG_M_DEBUG(msg) msg " " RPMDBG()
#define RPMDBG_M_NODEBUG(msg) NULL

#define RPMDBG_M(msg) RPMDBG_M_DEBUG(msg)

#endif /* H_DEBUG */
2 changes: 1 addition & 1 deletion lib/depends.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ int rpmtsAddInstallElement(rpmts ts, Header h,
}
mi = rpmdbFreeIterator(mi);

obsoletes = rpmdsLink(rpmteDS(p, RPMTAG_OBSOLETENAME), "Obsoletes");
obsoletes = rpmdsLink(rpmteDS(p, RPMTAG_OBSOLETENAME), RPMDBG_M("Obsoletes"));
obsoletes = rpmdsInit(obsoletes);
if (obsoletes != NULL)
while (rpmdsNext(obsoletes) >= 0) {
Expand Down
10 changes: 5 additions & 5 deletions lib/fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void * mapFreeIterator(void * p)
if (iter) {
/* XXX rpmswExit() */
iter->ts = rpmtsFree(iter->ts);
iter->fi = rpmfiUnlink(iter->fi, "mapIterator");
iter->fi = rpmfiUnlink(iter->fi, RPMDBG_M("mapFreeIterator"));
}
return _free(p);
}
Expand All @@ -111,8 +111,8 @@ mapInitIterator(rpmts ts, rpmfi fi)
FSMI_t iter = NULL;

iter = xcalloc(1, sizeof(*iter));
iter->ts = rpmtsLink(ts, "mapIterator");
iter->fi = rpmfiLink(fi, "mapIterator");
iter->ts = rpmtsLink(ts, RPMDBG_M("mapIterator"));
iter->fi = rpmfiLink(fi, RPMDBG_M("mapIterator"));
iter->reverse = (rpmteType(fi->te) == TR_REMOVED && fi->action != FA_COPYOUT);
iter->i = (iter->reverse ? (fi->fc - 1) : 0);
iter->isave = iter->i;
Expand Down Expand Up @@ -476,7 +476,7 @@ int fsmSetup(FSM_t fsm, fileStage goal,

fsm->goal = goal;
if (cfd != NULL) {
fsm->cfd = fdLink(cfd, "persist (fsm)");
fsm->cfd = fdLink(cfd, RPMDBG_M("persist (fsm)"));
pos = fdGetCpioPos(fsm->cfd);
fdSetCpioPos(fsm->cfd, 0);
}
Expand Down Expand Up @@ -525,7 +525,7 @@ int fsmTeardown(FSM_t fsm)

fsm->iter = mapFreeIterator(fsm->iter);
if (fsm->cfd != NULL) {
fsm->cfd = fdFree(fsm->cfd, "persist (fsm)");
fsm->cfd = fdFree(fsm->cfd, RPMDBG_M("persist (fsm)"));
fsm->cfd = NULL;
}
fsm->failedFile = NULL;
Expand Down
30 changes: 14 additions & 16 deletions lib/psm.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
int i;

memset(psm, 0, sizeof(*psm));
psm->ts = rpmtsLink(ts, "InstallSourcePackage");
psm->ts = rpmtsLink(ts, RPMDBG_M("InstallSourcePackage"));

rpmrc = rpmReadPackageFile(ts, fd, "InstallSourcePackage", &h);
rpmrc = rpmReadPackageFile(ts, fd, RPMDBG_M("InstallSourcePackage"), &h);
switch (rpmrc) {
case RPMRC_NOTTRUSTED:
case RPMRC_NOKEY:
Expand Down Expand Up @@ -269,13 +269,13 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
}

rpmteSetHeader(fi->te, fi->h);
fi->te->fd = fdLink(fd, "installSourcePackage");
fi->te->fd = fdLink(fd, RPMDBG_M("installSourcePackage"));
hge = fi->hge;
hfd = fi->hfd;

(void) rpmInstallLoadMacros(fi, fi->h);

psm->fi = rpmfiLink(fi, NULL);
psm->fi = rpmfiLink(fi, RPMDBG_M("rpmInstallLoadMacros"));
psm->te = fi->te;

if (cookie) {
Expand Down Expand Up @@ -1142,34 +1142,33 @@ static const char * pkgStageString(pkgStage a)
}
}

rpmpsm XrpmpsmUnlink(rpmpsm psm, const char * msg, const char * fn, unsigned ln)
rpmpsm rpmpsmUnlink(rpmpsm psm, const char * msg)
{
if (psm == NULL) return NULL;
if (_psm_debug && msg != NULL)
fprintf(stderr, "--> psm %p -- %d %s at %s:%u\n", psm, psm->nrefs, msg, fn, ln);
fprintf(stderr, "--> psm %p -- %d: %s\n", psm, psm->nrefs, msg);
psm->nrefs--;
return NULL;
}

rpmpsm XrpmpsmLink(rpmpsm psm, const char * msg, const char * fn, unsigned ln)
rpmpsm rpmpsmLink(rpmpsm psm, const char * msg)
{
if (psm == NULL) return NULL;
psm->nrefs++;

if (_psm_debug && msg != NULL)
fprintf(stderr, "--> psm %p ++ %d %s at %s:%u\n", psm, psm->nrefs, msg, fn, ln);
fprintf(stderr, "--> psm %p ++ %d %s\n", psm, psm->nrefs, msg);

return psm;
}

rpmpsm rpmpsmFree(rpmpsm psm)
{
const char * msg = "rpmpsmFree";
if (psm == NULL)
return NULL;

if (psm->nrefs > 1)
return rpmpsmUnlink(psm, msg);
return rpmpsmUnlink(psm, RPMDBG_M("rpmpsmFree"));

psm->fi = rpmfiFree(psm->fi);
#ifdef NOTYET
Expand All @@ -1179,7 +1178,7 @@ rpmpsm rpmpsmFree(rpmpsm psm)
#endif
psm->ts = rpmtsFree(psm->ts);

(void) rpmpsmUnlink(psm, msg);
(void) rpmpsmUnlink(psm, RPMDBG_M("rpmpsmFree"));

memset(psm, 0, sizeof(*psm)); /* XXX trash and burn */
psm = _free(psm);
Expand All @@ -1189,18 +1188,17 @@ rpmpsm rpmpsmFree(rpmpsm psm)

rpmpsm rpmpsmNew(rpmts ts, rpmte te, rpmfi fi)
{
const char * msg = "rpmpsmNew";
rpmpsm psm = xcalloc(1, sizeof(*psm));

if (ts) psm->ts = rpmtsLink(ts, msg);
if (ts) psm->ts = rpmtsLink(ts, RPMDBG_M("rpmpsmNew"));
#ifdef NOTYET
if (te) psm->te = rpmteLink(te, msg);
if (te) psm->te = rpmteLink(te, RPMDBG_M("rpmpsmNew"));
#else
if (te) psm->te = te;
#endif
if (fi) psm->fi = rpmfiLink(fi, msg);
if (fi) psm->fi = rpmfiLink(fi, RPMDBG_M("rpmpsmNew"));

return rpmpsmLink(psm, msg);
return rpmpsmLink(psm, RPMDBG_M("rpmpsmNew"));
}

static void * rpmpsmThread(void * arg)
Expand Down
10 changes: 0 additions & 10 deletions lib/psm.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ extern "C" {
rpmpsm rpmpsmUnlink (rpmpsm psm,
const char * msg);

/** @todo Remove debugging entry from the ABI. */
rpmpsm XrpmpsmUnlink (rpmpsm psm,
const char * msg, const char * fn, unsigned ln);
#define rpmpsmUnlink(_psm, _msg) XrpmpsmUnlink(_psm, _msg, __FILE__, __LINE__)

/**
* Reference a package state machine instance.
* @param psm package state machine
Expand All @@ -122,11 +117,6 @@ rpmpsm XrpmpsmUnlink (rpmpsm psm,
*/
rpmpsm rpmpsmLink (rpmpsm psm, const char * msg);

/** @todo Remove debugging entry from the ABI. */
rpmpsm XrpmpsmLink (rpmpsm psm, const char * msg,
const char * fn, unsigned ln);
#define rpmpsmLink(_psm, _msg) XrpmpsmLink(_psm, _msg, __FILE__, __LINE__)

/**
* Destroy a package state machine.
* @param psm package state machine
Expand Down
8 changes: 4 additions & 4 deletions lib/rpmal.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,10 @@ rpmalKey rpmalAdd(rpmal * alistp, rpmalKey pkgKey, fnpyKey key,
if (_rpmal_debug)
fprintf(stderr, "*** add %p[%d] 0x%x\n", al->list, (int) pkgNum, tscolor);

alp->provides = rpmdsLink(provides, "Provides (rpmalAdd)");
alp->fi = rpmfiLink(fi, "Files (rpmalAdd)");
alp->provides = rpmdsLink(provides, RPMDBG_M("Provides (rpmalAdd)"));
alp->fi = rpmfiLink(fi, RPMDBG_M("Files (rpmalAdd)"));

fi = rpmfiLink(alp->fi, "Files index (rpmalAdd)");
fi = rpmfiLink(alp->fi, RPMDBG_M("Files index (rpmalAdd)"));
fi = rpmfiInit(fi, 0);
if (rpmfiFC(fi) > 0) {
dirInfo dieNeedle =
Expand Down Expand Up @@ -483,7 +483,7 @@ fprintf(stderr, "\t%p[%3d] %p:%p[%2d] %s\n", die->files, die->numFiles, fie, fie
if (origNumDirs != al->numDirs)
qsort(al->dirs, al->numDirs, sizeof(*al->dirs), dieCompare);
}
fi = rpmfiUnlink(fi, "Files index (rpmalAdd)");
fi = rpmfiUnlink(fi, RPMDBG_M("Files index (rpmalAdd)"));

rpmalFreeIndex(al);

Expand Down
4 changes: 2 additions & 2 deletions lib/rpmchecksig.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ static int manageFile(FD_t *fdp,
}
if (fnp != NULL)
*fnp = fn;
*fdp = fdLink(fd, "manageFile return");
fd = fdFree(fd, "manageFile return");
*fdp = fdLink(fd, RPMDBG_M("manageFile return"));
fd = fdFree(fd, RPMDBG_M("manageFile return"));
return 0;
}

Expand Down
12 changes: 6 additions & 6 deletions lib/rpmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ struct rpmds_s {
int nopromote; /*!< Don't promote Epoch: in rpmdsCompare()? */
int nrefs; /*!< Reference count. */
};
rpmds XrpmdsUnlink(rpmds ds, const char * msg, const char * fn, unsigned ln)
rpmds rpmdsUnlink(rpmds ds, const char * msg)
{
if (ds == NULL) return NULL;
if (_rpmds_debug && msg != NULL)
fprintf(stderr, "--> ds %p -- %d %s at %s:%u\n", ds, ds->nrefs, msg, fn, ln);
fprintf(stderr, "--> ds %p -- %d %s\n", ds, ds->nrefs, msg);
ds->nrefs--;
return NULL;
}

rpmds XrpmdsLink(rpmds ds, const char * msg, const char * fn, unsigned ln)
rpmds rpmdsLink(rpmds ds, const char * msg)
{
if (ds == NULL) return NULL;
ds->nrefs++;

if (_rpmds_debug && msg != NULL)
fprintf(stderr, "--> ds %p ++ %d %s at %s:%u\n", ds, ds->nrefs, msg, fn, ln);
fprintf(stderr, "--> ds %p ++ %d %s\n", ds, ds->nrefs, msg);

return ds;
}
Expand Down Expand Up @@ -192,7 +192,7 @@ fprintf(stderr, "*** ds %p\t%s[%d]\n", ds, ds->Type, ds->Count);

exit:
/* FIX: ds->Flags may be NULL */
ds = rpmdsLink(ds, (ds ? ds->Type : NULL));
ds = rpmdsLink(ds, (ds ? ds->Type : RPMDBG()));

return ds;
}
Expand Down Expand Up @@ -311,7 +311,7 @@ rpmds rpmdsThis(Header h, rpmTag tagN, int32_t Flags)
}

exit:
return rpmdsLink(ds, (ds ? ds->Type : NULL));
return rpmdsLink(ds, (ds ? ds->Type : RPMDBG()));
}

rpmds rpmdsSingle(rpmTag tagN, const char * N, const char * EVR, int32_t Flags)
Expand Down
14 changes: 1 addition & 13 deletions lib/rpmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,7 @@ typedef enum rpmsenseFlags_e {
* @param msg
* @return NULL always
*/
rpmds rpmdsUnlink (rpmds ds,
const char * msg);

/** @todo Remove debugging entry from the ABI. */
rpmds XrpmdsUnlink (rpmds ds,
const char * msg, const char * fn, unsigned ln);
#define rpmdsUnlink(_ds, _msg) XrpmdsUnlink(_ds, _msg, __FILE__, __LINE__)

rpmds rpmdsUnlink (rpmds ds, const char * msg);
/** \ingroup rpmds
* Reference a dependency set instance.
* @param ds dependency set
Expand All @@ -112,11 +105,6 @@ rpmds XrpmdsUnlink (rpmds ds,
*/
rpmds rpmdsLink (rpmds ds, const char * msg);

/** @todo Remove debugging entry from the ABI. */
rpmds XrpmdsLink (rpmds ds, const char * msg,
const char * fn, unsigned ln);
#define rpmdsLink(_ds, _msg) XrpmdsLink(_ds, _msg, __FILE__, __LINE__)

/** \ingroup rpmds
* Destroy a dependency set.
* @param ds dependency set
Expand Down
8 changes: 4 additions & 4 deletions lib/rpmfi.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@

int _rpmfi_debug = 0;

rpmfi XrpmfiUnlink(rpmfi fi, const char * msg, const char * fn, unsigned ln)
rpmfi rpmfiUnlink(rpmfi fi, const char * msg)
{
if (fi == NULL) return NULL;
if (_rpmfi_debug && msg != NULL)
fprintf(stderr, "--> fi %p -- %d %s at %s:%u\n", fi, fi->nrefs, msg, fn, ln);
fprintf(stderr, "--> fi %p -- %d %s\n", fi, fi->nrefs, msg);
fi->nrefs--;
return NULL;
}

rpmfi XrpmfiLink(rpmfi fi, const char * msg, const char * fn, unsigned ln)
rpmfi rpmfiLink(rpmfi fi, const char * msg)
{
if (fi == NULL) return NULL;
fi->nrefs++;
if (_rpmfi_debug && msg != NULL)
fprintf(stderr, "--> fi %p ++ %d %s at %s:%u\n", fi, fi->nrefs, msg, fn, ln);
fprintf(stderr, "--> fi %p ++ %d %s\n", fi, fi->nrefs, msg);
return fi;
}

Expand Down
22 changes: 0 additions & 22 deletions lib/rpmfi.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ typedef enum rpmFileAction_e {
rpmfi rpmfiUnlink (rpmfi fi,
const char * msg);

/** @todo Remove debugging entry from the ABI.
* @param fi file info set
* @param msg
* @param fn
* @param ln
* @return NULL always
*/
rpmfi XrpmfiUnlink (rpmfi fi,
const char * msg, const char * fn, unsigned ln);
#define rpmfiUnlink(_fi, _msg) XrpmfiUnlink(_fi, _msg, __FILE__, __LINE__)

/** \ingroup rpmfi
* Reference a file info set instance.
* @param fi file info set
Expand All @@ -114,17 +103,6 @@ rpmfi XrpmfiUnlink (rpmfi fi,
*/
rpmfi rpmfiLink (rpmfi fi, const char * msg);

/** @todo Remove debugging entry from the ABI.
* @param fi file info set
* @param msg
* @param fn
* @param ln
* @return NULL always
*/
rpmfi XrpmfiLink (rpmfi fi, const char * msg,
const char * fn, unsigned ln);
#define rpmfiLink(_fi, _msg) XrpmfiLink(_fi, _msg, __FILE__, __LINE__)

/** \ingroup rpmfi
* Return file count from file info set.
* @param fi file info set
Expand Down
Loading

0 comments on commit dbdbe80

Please sign in to comment.