From f0882dbdfdc4b8d1086b5c93456d20e0f3580353 Mon Sep 17 00:00:00 2001 From: rlar Date: Wed, 17 Jul 2013 20:30:54 +0200 Subject: [PATCH] CKTfndMod(), return the found model instead of error code --- src/frontend/spiceif.c | 4 ++-- src/include/ngspice/cktdefs.h | 2 +- src/include/ngspice/ifsim.h | 2 +- src/spicelib/analysis/cktfndm.c | 14 +++++++------- src/spicelib/analysis/cktmcrt.c | 2 +- src/spicelib/devices/urc/urcsetup.c | 4 ++-- src/tclspice.c | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c index 0fb1d6c31..27312f8fb 100644 --- a/src/frontend/spiceif.c +++ b/src/frontend/spiceif.c @@ -624,7 +624,7 @@ finddev_special( // assert(second && *second == -1) // assert(third && *third == NULL) - err = ft_sim->findModel (ckt, &type, modptr, name); + *modptr = ft_sim->findModel (ckt, &type, modptr, name); err = *modptr ? OK : E_NOMOD; if (err == OK) { *device_or_model = 1; @@ -1225,7 +1225,7 @@ finddev(CKTcircuit *ckt, char *name, GENinstance **devptr, GENmodel **modptr) // assert(second && *second == -1) // assert(third && *third == NULL) - err = ft_sim->findModel (ckt, &type, modptr, name); + *modptr = ft_sim->findModel (ckt, &type, modptr, name); err = *modptr ? OK : E_NOMOD; if (err == OK) return (type); diff --git a/src/include/ngspice/cktdefs.h b/src/include/ngspice/cktdefs.h index 4c3d85717..b91c57343 100644 --- a/src/include/ngspice/cktdefs.h +++ b/src/include/ngspice/cktdefs.h @@ -320,7 +320,7 @@ extern void CKTncDump(CKTcircuit *); extern int CKTfndAnal(CKTcircuit *, int *, JOB **, IFuid , TSKtask *, IFuid); extern int CKTfndBranch(CKTcircuit *, IFuid); extern GENinstance *CKTfndDev(CKTcircuit *, IFuid); -extern int CKTfndMod(CKTcircuit *, int *, GENmodel **, IFuid); +extern GENmodel *CKTfndMod(CKTcircuit *, int *, GENmodel **, IFuid); extern int CKTfndNode(CKTcircuit *, CKTnode **, IFuid); extern int CKTfndTask(CKTcircuit *, TSKtask **, IFuid ); extern int CKTground(CKTcircuit *, CKTnode **, IFuid); diff --git a/src/include/ngspice/ifsim.h b/src/include/ngspice/ifsim.h index b2cc74703..f509bdfb2 100644 --- a/src/include/ngspice/ifsim.h +++ b/src/include/ngspice/ifsim.h @@ -381,7 +381,7 @@ struct IFsimulator { /* set a parameter on a model */ int (*askModelQuest) (CKTcircuit *, GENmodel *, int, IFvalue *, IFvalue *); /* ask a questions about a model */ - int (*findModel) (CKTcircuit *, int *, GENmodel **, IFuid); + GENmodel *(*findModel) (CKTcircuit *, int *, GENmodel **, IFuid); /* find a specific model */ int (*deleteModel) (CKTcircuit *, GENmodel *); /* delete a model from the circuit*/ diff --git a/src/spicelib/analysis/cktfndm.c b/src/spicelib/analysis/cktfndm.c index 250544c62..d4eec4ca8 100644 --- a/src/spicelib/analysis/cktfndm.c +++ b/src/spicelib/analysis/cktfndm.c @@ -13,7 +13,7 @@ Author: 1985 Thomas L. Quarles -int +GENmodel * CKTfndMod(CKTcircuit *ckt, int *type, GENmodel **modfast, IFuid modname) { GENmodel *mods; @@ -21,7 +21,7 @@ CKTfndMod(CKTcircuit *ckt, int *type, GENmodel **modfast, IFuid modname) if(modfast != NULL && *modfast != NULL) { /* already have modfast, so nothing to do */ if(type) *type = (*modfast)->GENmodType; - return(OK); + return *modfast; } if(*type >=0 && *type < DEVmaxnum) { /* have device type, need to find model */ @@ -30,10 +30,10 @@ CKTfndMod(CKTcircuit *ckt, int *type, GENmodel **modfast, IFuid modname) mods = mods->GENnextModel) { if(mods->GENmodName == modname) { *modfast = mods; - return(OK); + return *modfast; } } - return(E_NOMOD); + return NULL; } else if(*type == -1) { /* look through all types (UGH - worst case - take forever) */ for(*type = 0;*type GENnextModel) { if(mods->GENmodName == modname) { *modfast = mods; - return(OK); + return *modfast; } } } *type = -1; - return(E_NOMOD); - } else return(E_NOMOD); + return NULL; + } else return NULL; } diff --git a/src/spicelib/analysis/cktmcrt.c b/src/spicelib/analysis/cktmcrt.c index dfa1c1d1c..5406d47af 100644 --- a/src/spicelib/analysis/cktmcrt.c +++ b/src/spicelib/analysis/cktmcrt.c @@ -25,7 +25,7 @@ CKTmodCrt(CKTcircuit *ckt, int type, GENmodel **modfast, IFuid name) // assert(second) // assert(third && *third == NULL) - error = CKTfndMod(ckt, &type, &mymodfast, name); + mymodfast = CKTfndMod(ckt, &type, &mymodfast, name); error = mymodfast ? OK : E_NOMOD; if(error == E_NOMOD) { mymodfast = (GENmodel *) tmalloc((size_t) *(DEVices[type]->DEVmodSize)); diff --git a/src/spicelib/devices/urc/urcsetup.c b/src/spicelib/devices/urc/urcsetup.c index 82f857735..9b965ce85 100644 --- a/src/spicelib/devices/urc/urcsetup.c +++ b/src/spicelib/devices/urc/urcsetup.c @@ -310,7 +310,7 @@ URCunsetup(GENmodel *inModel, CKTcircuit *ckt) type = -1; // assert(second && *second == -1) // assert(third && *third == NULL) - error = CKTfndMod(ckt, &type, &modfast, varUid); + modfast = CKTfndMod(ckt, &type, &modfast, varUid); error = modfast ? OK : E_NOMOD; if (error) return error; @@ -330,7 +330,7 @@ URCunsetup(GENmodel *inModel, CKTcircuit *ckt) type = -1; // assert(second && *second == -1) // assert(third && *third == NULL) - error = CKTfndMod(ckt, &type, &modfast, varUid); + modfast = CKTfndMod(ckt, &type, &modfast, varUid); error = modfast ? OK : E_NOMOD; if (error) return error; diff --git a/src/tclspice.c b/src/tclspice.c index 24ca9434d..0cbe08f88 100644 --- a/src/tclspice.c +++ b/src/tclspice.c @@ -1399,7 +1399,7 @@ get_mod_param TCL_CMDPROCARGS(clientData, interp, argc, argv) typecode = -1; // assert(second && *second == -1) // assert(third && *third == NULL) - err = ft_sim->findModel (ft_curckt->ci_ckt, &typecode, &modptr, name); + modptr = ft_sim->findModel (ft_curckt->ci_ckt, &typecode, &modptr, name); err = modptr ? OK : E_NOMOD; } else { typecode = devptr->GENmodPtr->GENmodType;