From b3860ac5991e90589cd7ee9efddd4cbbb1828fc0 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 12 Apr 2015 18:17:52 +0200 Subject: [PATCH] devices/asrc, rewrite #6/10, check for errors right at the beginning --- src/spicelib/devices/asrc/asrcset.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/spicelib/devices/asrc/asrcset.c b/src/spicelib/devices/asrc/asrcset.c index 6023fa5ad..d053c56fb 100644 --- a/src/spicelib/devices/asrc/asrcset.c +++ b/src/spicelib/devices/asrc/asrcset.c @@ -27,6 +27,15 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) for (; model; model = model->ASRCnextModel) { for (here = model->ASRCinstances; here; here=here->ASRCnextInstance) { + if (!here->ASRCtree) + return E_PARMVAL; + + if (here->ASRCtype == ASRC_VOLTAGE) + if (here->ASRCposNode == here->ASRCnegNode) { + SPfrontEnd->IFerrorf(ERR_FATAL, "instance %s is a shorted ASRC", here->ASRCname); + return(E_UNSUPP); + } + if (!here->ASRCtc1Given) here->ASRCtc1 = 0.0; if (!here->ASRCtc2Given) @@ -58,16 +67,8 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) /* For each controlling variable set the entries in the vector of the positions of the SMP */ - if (!here->ASRCtree) - return E_PARMVAL; - if (here->ASRCtype == ASRC_VOLTAGE) { - if (here->ASRCposNode == here->ASRCnegNode) { - SPfrontEnd->IFerrorf(ERR_FATAL, "instance %s is a shorted ASRC", here->ASRCname); - return(E_UNSUPP); - } - here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 4); TSTALLOC(ASRCposptr[j++], here->ASRCposNode, here->ASRCbranch);