Push problem creation argument sanitation to the level below
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 26 Mar 2010 08:41:10 +0000 (10:41 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 26 Mar 2010 08:43:40 +0000 (10:43 +0200)
- 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
lib/rpmprob.h
lib/rpmps.c
lib/rpmps.h
lib/rpmte.c

index 511a5b1..225e4b9 100644 (file)
@@ -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);
 }
 
index e23e839..296877e 100644 (file)
@@ -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.
index 6089e38..c353dcd 100644 (file)
@@ -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);
 }
index 9414d2d..e0d36c8 100644 (file)
@@ -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.
index b744be7..5dc11f5 100644 (file)
@@ -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);
     }
 }