From: Michael Schroeder Date: Thu, 8 Dec 2022 10:54:08 +0000 (+0100) Subject: Small code cleanup, no functional changes X-Git-Tag: 0.7.23~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5343868f1453311f4628de34fd99996f8711178c;p=thirdparty%2Flibsolv.git Small code cleanup, no functional changes --- diff --git a/src/decision.c b/src/decision.c index 7a60b2d9..50ff3a95 100644 --- a/src/decision.c +++ b/src/decision.c @@ -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]; diff --git a/tools/testsolv.c b/tools/testsolv.c index e483cb2a..572a9ca0 100644 --- a/tools/testsolv.c +++ b/tools/testsolv.c @@ -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])