chiark / gitweb /
realtime/movpos: fix some partially unitialised structs, and fix some non-newline...
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 8 Jan 2011 23:21:11 +0000 (23:21 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 8 Jan 2011 23:21:11 +0000 (23:21 +0000)
hostside/movpos.c

index a662ee6576b916622d092d4704b3546e2ffcfd0e..541d273b951196411508be845f92e2a6dced12eb 100644 (file)
@@ -818,15 +818,21 @@ static ErrorCode indep_prepare(Segment *move, MovPosComb target,
     for (methi=0; methi<n_meths; methi++)
       if (meths[methi] == meth) goto found_method;
     /* need a new method */
-    methi= ++n_meths;
-    if (methi >= EVAL_MAX_METHODS) return EC_MovFeatTooManyMethods;
+    methi= n_meths++;
+    if (methi >= EVAL_MAX_METHODS) {
+      DPRINTF2(" MovFeatTooManyMethods methi=%d\n",methi);
+      return EC_MovFeatTooManyMethods;
+    }
     meths[methi]= meth;
     n_motions[methi]= 0;
     DPRINTF2(" meths[%d]=%s", methi,meth->pname);
 
   found_method:;
-    int motioni= ++n_motions[methi];
-    if (motioni >= EVAL_MAX_MOTIONS) return EC_MovFeatTooManyMotions;
+    int motioni= n_motions[methi]++;
+    if (motioni >= EVAL_MAX_MOTIONS) {
+      DPRINTF2(" MovFeatTooManyMotions motioni=%d\n",motioni);
+      return EC_MovFeatTooManyMotions;
+    }
     DPRINTF2(" motion[%d][%d]=%s%d", methi, motioni, feati->pname,posn);
     motions[methi][motioni].i= feati;
     motions[methi][motioni].posn= posn;
@@ -835,10 +841,11 @@ static ErrorCode indep_prepare(Segment *move, MovPosComb target,
   if (indep_r) {
     DPRINTF2(" alloc");
     indep= mmalloc(sizeof(*indep) + sizeof(Change*) * n_meths);
-    memset(indep->changes, 0, sizeof(Change*) * n_meths);
     indep->move= move;
     indep->actual= startpoint;
     indep->target= target;
+    indep->n_changes= n_meths;
+    memset(indep->changes, 0, sizeof(Change*) * n_meths);
   }
   DPRINTF2("\n");
 
@@ -869,6 +876,7 @@ static ErrorCode indep_prepare(Segment *move, MovPosComb target,
       Change *chg= indep->changes[changei];
       chg->meth= meth;
       chg->indep= indep;
+      chg->installed= 0;
     }
     totalcost += thiscost;
   }