From a0977a74fe1007303ac7d96dbff5f97370069b29 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 8 Jan 2011 23:21:11 +0000 Subject: [PATCH] realtime/movpos: fix some partially unitialised structs, and fix some non-newline-terminated debugging messages in error paths --- hostside/movpos.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hostside/movpos.c b/hostside/movpos.c index a662ee6..541d273 100644 --- a/hostside/movpos.c +++ b/hostside/movpos.c @@ -818,15 +818,21 @@ static ErrorCode indep_prepare(Segment *move, MovPosComb target, for (methi=0; 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; } -- 2.30.2