Clean up verifyDependencies() a bit, no functional changes
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 25 Mar 2010 09:34:24 +0000 (11:34 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 25 Mar 2010 09:34:24 +0000 (11:34 +0200)
- only init problem iterator if there are problems
- use problems and nevra from the faked up transaction element
- the return code is the number of problems, no need to count separately

lib/verify.c

index 9d115f9..e68297d 100644 (file)
@@ -391,36 +391,33 @@ static int verifyHeader(QVA_t qva, const rpmts ts, Header h)
  * @param h            header
  * @return             number of problems found (0 for no problems)
  */
-static int verifyDependencies(QVA_t qva, rpmts ts,
-               Header h)
+static int verifyDependencies(QVA_t qva, rpmts ts, Header h)
 {
     rpmps ps;
-    rpmpsi psi;
-    int rc = 0;                /* assume no problems */
-    int xx;
+    rpmte te;
+    int rc;
 
     rpmtsEmpty(ts);
     (void) rpmtsAddInstallElement(ts, h, NULL, 0, NULL);
 
-    xx = rpmtsCheck(ts);
-    ps = rpmtsProblems(ts);
+    (void) rpmtsCheck(ts);
+    te = rpmtsElement(ts, 0);
+    ps = rpmteProblems(te);
+    rc = rpmpsNumProblems(ps);
+
+    if (rc > 0) {
+       rpmlog(RPMLOG_NOTICE, _("Unsatisfied dependencies for %s:\n"),
+              rpmteNEVRA(te));
+       rpmpsi psi = rpmpsInitIterator(ps);
 
-    psi = rpmpsInitIterator(ps);
-    if (rpmpsNumProblems(ps) > 0) {
-       char *nevra = headerGetAsString(h, RPMTAG_NEVRA);
-       rpmlog(RPMLOG_NOTICE, _("Unsatisfied dependencies for %s:\n"), nevra);
-       free(nevra);
        while (rpmpsNextIterator(psi) >= 0) {
-           rpmProblem p = rpmpsGetProblem(psi);
-           char * ps = rpmProblemString(p);
+           char * ps = rpmProblemString(rpmpsGetProblem(psi));
            rpmlog(RPMLOG_NOTICE, "\t%s\n", ps);
            free(ps);
-           rc++;       
        }
+       psi = rpmpsFreeIterator(psi);
     }
-    psi = rpmpsFreeIterator(psi);
     ps = rpmpsFree(ps);
-
     rpmtsEmpty(ts);
 
     return rc;