From 1102e35b20ebebb897785266bd6ba6b8a7aab323 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 26 Mar 2010 10:41:10 +0200 Subject: [PATCH] Push problem creation argument sanitation to the level below - rpmpsAppend() and rpmProblemCreate() have no use for fn/dn either, its just stored in one string internally - this is kinda unnecessary API break but these aren't used outside rpm so it doesn't make much difference --- lib/rpmprob.c | 16 +++------------- lib/rpmprob.h | 9 +++------ lib/rpmps.c | 7 +++---- lib/rpmps.h | 10 +++------- lib/rpmte.c | 4 ++-- 5 files changed, 14 insertions(+), 32 deletions(-) diff --git a/lib/rpmprob.c b/lib/rpmprob.c index 511a5b1..225e4b9 100644 --- a/lib/rpmprob.c +++ b/lib/rpmprob.c @@ -23,14 +23,11 @@ struct rpmProblem_s { }; rpmProblem rpmProblemCreate(rpmProblemType type, - const char * pkgNEVR, - fnpyKey key, - const char * dn, const char * bn, + const char * pkgNEVR, fnpyKey key, const char * altNEVR, - uint64_t number) + const char * str, uint64_t number) { rpmProblem p = xcalloc(1, sizeof(*p)); - char *t; p->type = type; p->key = key; @@ -38,15 +35,8 @@ rpmProblem rpmProblemCreate(rpmProblemType type, p->pkgNEVR = (pkgNEVR ? xstrdup(pkgNEVR) : NULL); p->altNEVR = (altNEVR ? xstrdup(altNEVR) : NULL); + p->str1 = (str ? xstrdup(str) : NULL); - p->str1 = NULL; - if (dn != NULL || bn != NULL) { - t = xcalloc(1, (dn != NULL ? strlen(dn) : 0) + - (bn != NULL ? strlen(bn) : 0) + 1); - p->str1 = t; - if (dn != NULL) t = stpcpy(t, dn); - if (bn != NULL) t = stpcpy(t, bn); - } return rpmProblemLink(p); } diff --git a/lib/rpmprob.h b/lib/rpmprob.h index e23e839..296877e 100644 --- a/lib/rpmprob.h +++ b/lib/rpmprob.h @@ -54,18 +54,15 @@ typedef enum rpmProblemType_e { * @param type type of problem * @param pkgNEVR package name * @param key filename or python object address - * @param dn directory name - * @param bn file base name * @param altNEVR related (e.g. through a dependency) package name + * @param str generic string attribute * @param number generic number attribute * @return rpmProblem */ rpmProblem rpmProblemCreate(rpmProblemType type, - const char * pkgNEVR, - fnpyKey key, - const char * dn, const char * bn, + const char * pkgNEVR, fnpyKey key, const char * altNEVR, - uint64_t number); + const char * str, uint64_t number); /** \ingroup rpmprob * Destroy a problem item. diff --git a/lib/rpmps.c b/lib/rpmps.c index 6089e38..c353dcd 100644 --- a/lib/rpmps.c +++ b/lib/rpmps.c @@ -140,14 +140,13 @@ void rpmpsAppendProblem(rpmps ps, rpmProblem prob) } void rpmpsAppend(rpmps ps, rpmProblemType type, - const char * pkgNEVR, fnpyKey key, - const char * dn, const char * bn, - const char * altNEVR, uint64_t number) + const char * pkgNEVR, fnpyKey key, const char * altNEVR, + const char * str, uint64_t number) { rpmProblem p = NULL; if (ps == NULL) return; - p = rpmProblemCreate(type, pkgNEVR, key, dn, bn, altNEVR, number); + p = rpmProblemCreate(type, pkgNEVR, key, altNEVR, str, number); rpmpsAppendProblem(ps, p); rpmProblemFree(p); } diff --git a/lib/rpmps.h b/lib/rpmps.h index 9414d2d..e0d36c8 100644 --- a/lib/rpmps.h +++ b/lib/rpmps.h @@ -108,17 +108,13 @@ void rpmpsAppendProblem(rpmps ps, rpmProblem prob); * @param type type of problem * @param pkgNEVR package name * @param key filename or python object address - * @param dn directory name - * @param bn file base name * @param altNEVR related (e.g. through a dependency) package name + * @param str generic string attribute * @param number generic number attribute */ void rpmpsAppend(rpmps ps, rpmProblemType type, - const char * pkgNEVR, - fnpyKey key, - const char * dn, const char * bn, - const char * altNEVR, - uint64_t number); + const char * pkgNEVR, fnpyKey key, const char * altNEVR, + const char *str, uint64_t number); /** \ingroup rpmps * Filter a problem set. diff --git a/lib/rpmte.c b/lib/rpmte.c index b744be7..5dc11f5 100644 --- a/lib/rpmte.c +++ b/lib/rpmte.c @@ -724,7 +724,7 @@ void rpmteAddProblem(rpmte te, rpmProblemType type, if (te->probs == NULL) te->probs = rpmpsCreate(); rpmpsAppend(te->probs, type, rpmteNEVRA(te), rpmteKey(te), - str, NULL, altNEVR, number); + altNEVR, str, number); } } @@ -746,7 +746,7 @@ void rpmteAddDepProblem(rpmte te, const char * pkgNEVR, rpmds ds, case 'R': type = RPMPROB_REQUIRES; break; } - rpmpsAppend(te->probs, type, pkgNEVR, key, NULL, NULL, DNEVR, adding); + rpmpsAppend(te->probs, type, pkgNEVR, key, DNEVR, NULL, adding); } } -- 2.7.4