Avoid changing the file info sets when adding to rpmal file hash
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 5 Oct 2012 08:25:49 +0000 (11:25 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 5 Oct 2012 08:25:49 +0000 (11:25 +0300)
- Use indexed access to the file info sets so we're not mucking
  around with somebody elses rpmfi iterator index (currently not an
  issue but still...)

lib/rpmal.c

index d3bac97..1425339 100644 (file)
@@ -13,6 +13,7 @@
 #include "lib/misc.h"
 #include "lib/rpmte_internal.h"
 #include "lib/rpmds_internal.h"
+#include "lib/rpmfi_internal.h"
 
 #include "debug.h"
 
@@ -179,28 +180,27 @@ static void rpmalAddFiles(rpmal al, rpmalNum pkgNum, rpmfi fi)
 {
     struct fileNameEntry_s fileName;
     struct availableIndexEntry_s fileEntry;
-    int i;
+    int fc = rpmfiFC(fi);
     rpm_color_t ficolor;
     int skipdoc = (al->tsflags & RPMTRANS_FLAG_NODOCS);
     int skipconf = (al->tsflags & RPMTRANS_FLAG_NOCONFIGS);
 
     fileEntry.pkgNum = pkgNum;
 
-    fi = rpmfiInit(fi, 0);
-    while ((i = rpmfiNext(fi)) >= 0) {
+    for (int i = 0; i < fc; i++) {
        /* Ignore colored provides not in our rainbow. */
-        ficolor = rpmfiFColor(fi);
+        ficolor = rpmfiFColorIndex(fi, i);
         if (al->tscolor && ficolor && !(al->tscolor & ficolor))
             continue;
 
        /* Ignore files that wont be installed */
-       if (skipdoc && (rpmfiFFlags(fi) & RPMFILE_DOC))
+       if (skipdoc && (rpmfiFFlagsIndex(fi, i) & RPMFILE_DOC))
            continue;
-       if (skipconf && (rpmfiFFlags(fi) & RPMFILE_CONFIG))
+       if (skipconf && (rpmfiFFlagsIndex(fi, i) & RPMFILE_CONFIG))
            continue;
 
-       fileName.dirName = rpmfiDNId(fi);
-       fileName.baseName = rpmfiBNId(fi);
+       fileName.dirName = rpmfiDNIdIndex(fi, rpmfiDIIndex(fi, i));
+       fileName.baseName = rpmfiBNIdIndex(fi, i);
 
        fileEntry.entryIx = i;