Imported Upstream version 0.7.9
[platform/upstream/libsolv.git] / src / order.c
index c92c332..cba977b 100644 (file)
 #include "repo.h"
 #include "util.h"
 
-struct _TransactionElement {
+struct s_TransactionElement {
   Id p;                /* solvable id */
   Id edges;    /* pointer into edges data */
   Id mark;
 };
 
-struct _TransactionOrderdata {
-  struct _TransactionElement *tes;
+struct s_TransactionOrderdata {
+  struct s_TransactionElement *tes;
   int ntes;
   Id *invedgedata;
   int ninvedgedata;
@@ -57,7 +57,7 @@ struct _TransactionOrderdata {
 void
 transaction_clone_orderdata(Transaction *trans, Transaction *srctrans)
 {
-  struct _TransactionOrderdata *od = srctrans->orderdata;
+  struct s_TransactionOrderdata *od = srctrans->orderdata;
   if (!od)
     return;
   trans->orderdata = solv_calloc(1, sizeof(*trans->orderdata));
@@ -77,7 +77,7 @@ transaction_free_orderdata(Transaction *trans)
 {
   if (trans->orderdata)
     {
-      struct _TransactionOrderdata *od = trans->orderdata;
+      struct s_TransactionOrderdata *od = trans->orderdata;
       od->tes = solv_free(od->tes);
       od->invedgedata = solv_free(od->invedgedata);
       if (od->cycles)
@@ -91,7 +91,7 @@ transaction_free_orderdata(Transaction *trans)
 
 struct orderdata {
   Transaction *trans;
-  struct _TransactionElement *tes;
+  struct s_TransactionElement *tes;
   int ntes;
   Id *edgedata;
   int nedgedata;
@@ -102,14 +102,14 @@ struct orderdata {
   int ncycles;
 };
 
-static int
+static void
 addteedge(struct orderdata *od, int from, int to, int type)
 {
   int i;
-  struct _TransactionElement *te;
+  struct s_TransactionElement *te;
 
   if (from == to)
-    return 0;
+    return;
 
   /* printf("edge %d(%s) -> %d(%s) type %x\n", from, pool_solvid2str(pool, od->tes[from].p), to, pool_solvid2str(pool, od->tes[to].p), type); */
 
@@ -117,13 +117,10 @@ addteedge(struct orderdata *od, int from, int to, int type)
   for (i = te->edges; od->edgedata[i]; i += 2)
     if (od->edgedata[i] == to)
       break;
-  /* test of brokenness */
-  if (type == TYPE_BROKEN)
-    return od->edgedata[i] && (od->edgedata[i + 1] & TYPE_BROKEN) != 0 ? 1 : 0;
   if (od->edgedata[i])
     {
       od->edgedata[i + 1] |= type;
-      return 0;
+      return;
     }
   if (i + 1 == od->nedgedata)
     {
@@ -145,16 +142,15 @@ addteedge(struct orderdata *od, int from, int to, int type)
   od->edgedata[i + 1] = type;
   od->edgedata[i + 2] = 0;     /* end marker */
   od->nedgedata = i + 3;
-  return 0;
 }
 
-static int
+static void
 addedge(struct orderdata *od, Id from, Id to, int type)
 {
   Transaction *trans = od->trans;
   Pool *pool = trans->pool;
   Solvable *s;
-  struct _TransactionElement *te;
+  struct s_TransactionElement *te;
   int i;
 
   /* printf("addedge %d %d type %d\n", from, to, type); */
@@ -166,16 +162,15 @@ addedge(struct orderdata *od, Id from, Id to, int type)
        from = trans->transaction_installed[from - pool->installed->start];
       else
        {
-         int ret = 0;
          Queue ti;
          Id tibuf[5];
 
          queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
          transaction_all_obs_pkgs(trans, from, &ti);
          for (i = 0; i < ti.count; i++)
-           ret |= addedge(od, ti.elements[i], to, type);
+           addedge(od, ti.elements[i], to, type);
          queue_free(&ti);
-         return ret;
+         return;
        }
     }
   s = pool->solvables + to;
@@ -186,16 +181,15 @@ addedge(struct orderdata *od, Id from, Id to, int type)
        to = trans->transaction_installed[to - pool->installed->start];
       else
        {
-         int ret = 0;
          Queue ti;
          Id tibuf[5];
 
          queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
          transaction_all_obs_pkgs(trans, to, &ti);
          for (i = 0; i < ti.count; i++)
-           ret |= addedge(od, from, ti.elements[i], type);
+           addedge(od, from, ti.elements[i], type);
          queue_free(&ti);
-         return ret;
+         return;
        }
     }
 
@@ -204,16 +198,17 @@ addedge(struct orderdata *od, Id from, Id to, int type)
     if (te->p == to)
       break;
   if (i == od->ntes)
-    return 0;
+    return;
   to = i;
 
   for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
     if (te->p == from)
       break;
   if (i == od->ntes)
-    return 0;
+    return;
+  from = i;
 
-  return addteedge(od, i, to, type);
+  addteedge(od, from, to, type);
 }
 
 static inline int
@@ -531,7 +526,7 @@ breakcycle(struct orderdata *od, Id *cycle)
   Pool *pool = od->trans->pool;
   Id ddegmin, ddegmax, ddeg;
   int k, l;
-  struct _TransactionElement *te;
+  struct s_TransactionElement *te;
 
   l = 0;
   ddegmin = ddegmax = 0;
@@ -598,13 +593,14 @@ breakcycle(struct orderdata *od, Id *cycle)
   POOL_DEBUG(SOLV_DEBUG_STATS, "\n");
 }
 
+#if 0
 static inline void
 dump_tes(struct orderdata *od)
 {
   Pool *pool = od->trans->pool;
   int i, j;
   Queue obsq;
-  struct _TransactionElement *te, *te2;
+  struct s_TransactionElement *te, *te2;
 
   queue_init(&obsq);
   for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
@@ -628,11 +624,12 @@ dump_tes(struct orderdata *od)
        }
     }
 }
+#endif
 
 static void
 reachable(struct orderdata *od, Id i)
 {
-  struct _TransactionElement *te = od->tes + i;
+  struct s_TransactionElement *te = od->tes + i;
   int j, k;
 
   if (te->mark != 0)
@@ -660,7 +657,7 @@ addcycleedges(struct orderdata *od, Id *cycle, Queue *todo)
   Transaction *trans = od->trans;
   Pool *pool = trans->pool;
 #endif
-  struct _TransactionElement *te;
+  struct s_TransactionElement *te;
   int i, j, k, tail;
   int head;
 
@@ -780,7 +777,7 @@ transaction_order(Transaction *trans, int flags)
   Solvable *s;
   int i, j, k, numte, numedge;
   struct orderdata od;
-  struct _TransactionElement *te;
+  struct s_TransactionElement *te;
   Queue todo, obsq, samerepoq, uninstq;
   int cycstart, cycel;
   Id *cycle;
@@ -795,7 +792,7 @@ transaction_order(Transaction *trans, int flags)
   /* free old data if present */
   if (trans->orderdata)
     {
-      struct _TransactionOrderdata *od = trans->orderdata;
+      struct s_TransactionOrderdata *od = trans->orderdata;
       od->tes = solv_free(od->tes);
       od->invedgedata = solv_free(od->invedgedata);
       trans->orderdata = solv_free(trans->orderdata);
@@ -1066,10 +1063,9 @@ transaction_order(Transaction *trans, int flags)
 #if 0
 printf("do %s [%d]\n", pool_solvid2str(pool, te->p), temedianr[i]);
 #endif
-      s = pool->solvables + te->p;
       for (j = te->edges; od.invedgedata[j]; j++)
        {
-         struct _TransactionElement *te2 = od.tes + od.invedgedata[j];
+         struct s_TransactionElement *te2 = od.tes + od.invedgedata[j];
          assert(te2->mark > 0);
          if (--te2->mark == 0)
            {
@@ -1103,7 +1099,7 @@ printf("free %s [%d]\n", pool_solvid2str(pool, te2->p), temedianr[od.invedgedata
 
   if ((flags & (SOLVER_TRANSACTION_KEEP_ORDERDATA | SOLVER_TRANSACTION_KEEP_ORDERCYCLES)) != 0)
     {
-      struct _TransactionOrderdata *tod;
+      struct s_TransactionOrderdata *tod;
       trans->orderdata = tod = solv_calloc(1, sizeof(*trans->orderdata));
       if ((flags & SOLVER_TRANSACTION_KEEP_ORDERCYCLES) != 0)
        {
@@ -1137,8 +1133,8 @@ int
 transaction_order_add_choices(Transaction *trans, Id chosen, Queue *choices)
 {
   int i, j;
-  struct _TransactionOrderdata *od = trans->orderdata;
-  struct _TransactionElement *te;
+  struct s_TransactionOrderdata *od = trans->orderdata;
+  struct s_TransactionElement *te;
 
   if (!od)
      return choices->count;
@@ -1349,7 +1345,7 @@ transaction_check_order(Transaction *trans)
 void
 transaction_order_get_cycleids(Transaction *trans, Queue *q, int minseverity)
 {
-  struct _TransactionOrderdata *od = trans->orderdata;
+  struct s_TransactionOrderdata *od = trans->orderdata;
   Queue *cq;
   int i, cid, ncycles;
 
@@ -1377,7 +1373,7 @@ transaction_order_get_cycleids(Transaction *trans, Queue *q, int minseverity)
 int
 transaction_order_get_cycle(Transaction *trans, Id cid, Queue *q)
 {
-  struct _TransactionOrderdata *od = trans->orderdata;
+  struct s_TransactionOrderdata *od = trans->orderdata;
   Queue *cq;
   int cmin, cmax, severity;
   int ncycles;