]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Small code cleanup, no functional changes
authorMichael Schroeder <mls@suse.de>
Thu, 8 Dec 2022 10:54:08 +0000 (11:54 +0100)
committerMichael Schroeder <mls@suse.de>
Thu, 8 Dec 2022 10:54:08 +0000 (11:54 +0100)
src/decision.c
tools/testsolv.c

index 7a60b2d903182f2d404ef3b6bb20e818eac32a11..50ff3a95c3ef483c9ba3e525cf20dde0dbb1f860 100644 (file)
@@ -251,7 +251,7 @@ solver_describe_weakdep_decision(Solver *solv, Id p, Queue *whyq)
 }
 
 static int
-decisionsort(const void *va, const void *vb, void *vd)
+decisionsort_cmp(const void *va, const void *vb, void *vd)
 {
   Solver *solv = vd;
   Pool *pool = solv->pool;
@@ -308,8 +308,6 @@ decisionmerge(Solver *solv, Queue *q)
          bits = merged;
        }
       j -= 8;
-      if (j == i)
-       continue;
       for (; i < j; i += 8)
        q->elements[i + 3] = bits;
     }
@@ -422,6 +420,7 @@ solver_get_proof(Solver *solv, Id id, int flags, Queue *q)
 
   /* put learnt rule premises in front */
   MAPZERO(&seen);
+  MAPSET(&seen, 1);
   i = 0;
   if ((flags & SOLVER_DECISIONLIST_TYPEMASK) == SOLVER_DECISIONLIST_LEARNTRULE)
     {
@@ -438,12 +437,14 @@ solver_get_proof(Solver *solv, Id id, int flags, Queue *q)
          MAPSET(&seen, p >= 0 ? p : -p);
          i += 8;
        }
-      if (i > 8)
-       solv_sort(q->elements, i / 8, 8 * sizeof(Id), decisionsort, solv);
     }
 
   if (flags & SOLVER_DECISIONLIST_SORTED)
     {
+      /* sort premise block */
+      if (i > 8)
+       solv_sort(q->elements, i / 8, 8 * sizeof(Id), decisionsort_cmp, solv);
+
       /* move rules:
        *   if a package is installed, move conflicts right after
        *   if a package is conflicted, move requires right after
@@ -472,7 +473,7 @@ solver_get_proof(Solver *solv, Id id, int flags, Queue *q)
          if (k == i)
            continue;
          if (i + 8 < k)
-           solv_sort(q->elements + i, (k - i) / 8, 8 * sizeof(Id), decisionsort, solv);
+           solv_sort(q->elements + i, (k - i) / 8, 8 * sizeof(Id), decisionsort_cmp, solv);
          for (; i < k; i += 8)
            {
              Id truelit = q->elements[i];
index e483cb2a0839580c0faf10b3154dbe92b38b53c1..572a9ca046cf17a55af620c55a6c230e3832b428 100644 (file)
@@ -109,11 +109,11 @@ showwhy(Solver *solv, const char *showwhypkgstr)
 
       printf("%s %s:\n", v < 0 ? "conflicted" : "installed", testcase_solvid2str(pool, v >= 0 ? v : -v));
       /* special case some reasons where we want to show multiple rule infos or extra info */
-      if (reason == SOLVER_REASON_UNIT_RULE || reason == SOLVER_REASON_RESOLVE || reason == SOLVER_REASON_WEAKDEP)
+      if (reason == SOLVER_REASON_WEAKDEP || reason == SOLVER_REASON_UNIT_RULE || reason == SOLVER_REASON_RESOLVE)
        {
          if (reason == SOLVER_REASON_WEAKDEP)
            solver_allweakdepinfos(solv, v, &iq);
-         else
+         else if (info > 0)
            solver_allruleinfos(solv, info, &iq);
          if (iq.count)
            {
@@ -145,7 +145,7 @@ showwhy(Solver *solv, const char *showwhypkgstr)
 }
 
 void
-doshowproof(Solver *solv, Id problem, int flags, Queue *lq)
+doshowproof(Solver *solv, Id id, int flags, Queue *lq)
 {
   Pool *pool = solv->pool;
   Queue q, qp;
@@ -153,7 +153,7 @@ doshowproof(Solver *solv, Id problem, int flags, Queue *lq)
 
   queue_init(&q);
   queue_init(&qp);
-  solver_get_decisionlist(solv, problem, flags | SOLVER_DECISIONLIST_SORTED | SOLVER_DECISIONLIST_WITHINFO | SOLVER_DECISIONLIST_MERGEDINFO, &q);
+  solver_get_decisionlist(solv, id, flags | SOLVER_DECISIONLIST_SORTED | SOLVER_DECISIONLIST_WITHINFO | SOLVER_DECISIONLIST_MERGEDINFO, &q);
   for (i = 0; i < q.count; i += 8)
     {
       Id v = q.elements[i];
@@ -170,12 +170,12 @@ doshowproof(Solver *solv, Id problem, int flags, Queue *lq)
         printf("unsolvable: ");
       else
         printf("%s %s: ", v < 0 ? "conflicted" : "installed", pool_solvidset2str(pool, &qp));
-      if (reason == SOLVER_REASON_PREMISE)
+      if (type == 0)
        {
          printf("%s\n", solver_reason2str(solv, reason));
          continue;
        }
-      if (lq && type == SOLVER_RULE_LEARNT)
+      if (type == SOLVER_RULE_LEARNT && lq)
        {
          for (j = 0; j < lq->count; j++)
            if (lq->elements[j] == q.elements[i + 2])