Add a some transition-period asserts to ensure pool-usage sanity
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 12 Sep 2012 13:50:41 +0000 (16:50 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 12 Sep 2012 16:19:31 +0000 (19:19 +0300)
lib/rpmal.c

index 577a39c..a79c697 100644 (file)
@@ -90,6 +90,9 @@ rpmal rpmalCreate(rpmstrPool pool, int delta, rpmtransFlags tsflags,
 {
     rpmal al = xcalloc(1, sizeof(*al));
 
+    /* transition time safe-guard */
+    assert(pool != NULL);
+
     al->pool = rpmstrPoolLink(pool);
     al->delta = delta;
     al->size = 0;
@@ -247,6 +250,22 @@ void rpmalAdd(rpmal al, rpmte p)
     alp->provides = rpmdsLink(rpmteDS(p, RPMTAG_PROVIDENAME));
     alp->fi = rpmfiLink(rpmteFI(p));
 
+    /*
+     * Transition-time safe-guard to catch private-pool uses.
+     * File sets with no files have NULL pool, that's fine. But WTF is up
+     * with the provides: every single package should have at least its
+     * own name as a provide, and thus never NULL, and normal use matches
+     * this expectation. However the test-suite is tripping up on NULL
+     * NULL pool from NULL alp->provides in numerous cases?
+     */
+    {
+       rpmstrPool fipool = rpmfiPool(alp->fi);
+       rpmstrPool dspool = rpmdsPool(alp->provides);
+       
+       assert(fipool == NULL || fipool == al->pool);
+       assert(dspool == NULL || dspool == al->pool);
+    }
+
     if (al->providesHash != NULL) { // index is already created
        rpmalAddProvides(al, pkgNum, alp->provides);
        rpmalAddFiles(al, pkgNum, alp->fi);