CKTfndMod(), rewrite error expressions
This commit is contained in:
parent
f0882dbdfd
commit
213304f745
|
|
@ -611,7 +611,6 @@ finddev_special(
|
|||
GENmodel **modptr,
|
||||
int *device_or_model)
|
||||
{
|
||||
int err;
|
||||
int type = -1;
|
||||
|
||||
*devptr = ft_sim->findInstance (ckt, name);
|
||||
|
|
@ -625,8 +624,7 @@ finddev_special(
|
|||
// assert(second && *second == -1)
|
||||
// assert(third && *third == NULL)
|
||||
*modptr = ft_sim->findModel (ckt, &type, modptr, name);
|
||||
err = *modptr ? OK : E_NOMOD;
|
||||
if (err == OK) {
|
||||
if (*modptr) {
|
||||
*device_or_model = 1;
|
||||
return (type);
|
||||
}
|
||||
|
|
@ -1214,7 +1212,6 @@ doset(CKTcircuit *ckt, int typecode, GENinstance *dev, GENmodel *mod, IFparm *op
|
|||
static int
|
||||
finddev(CKTcircuit *ckt, char *name, GENinstance **devptr, GENmodel **modptr)
|
||||
{
|
||||
int err;
|
||||
int type = -1;
|
||||
|
||||
*devptr = ft_sim->findInstance (ckt, name);
|
||||
|
|
@ -1226,8 +1223,7 @@ finddev(CKTcircuit *ckt, char *name, GENinstance **devptr, GENmodel **modptr)
|
|||
// assert(second && *second == -1)
|
||||
// assert(third && *third == NULL)
|
||||
*modptr = ft_sim->findModel (ckt, &type, modptr, name);
|
||||
err = *modptr ? OK : E_NOMOD;
|
||||
if (err == OK)
|
||||
if (*modptr)
|
||||
return (type);
|
||||
|
||||
*modptr = NULL;
|
||||
|
|
|
|||
|
|
@ -21,13 +21,11 @@ int
|
|||
CKTmodCrt(CKTcircuit *ckt, int type, GENmodel **modfast, IFuid name)
|
||||
{
|
||||
GENmodel *mymodfast = NULL;
|
||||
int error;
|
||||
|
||||
// assert(second)
|
||||
// assert(third && *third == NULL)
|
||||
mymodfast = CKTfndMod(ckt, &type, &mymodfast, name);
|
||||
error = mymodfast ? OK : E_NOMOD;
|
||||
if(error == E_NOMOD) {
|
||||
if(!mymodfast) {
|
||||
mymodfast = (GENmodel *) tmalloc((size_t) *(DEVices[type]->DEVmodSize));
|
||||
if(mymodfast == NULL) return(E_NOMEM);
|
||||
mymodfast->GENmodType = type;
|
||||
|
|
@ -36,11 +34,9 @@ CKTmodCrt(CKTcircuit *ckt, int type, GENmodel **modfast, IFuid name)
|
|||
ckt->CKThead[type] = mymodfast;
|
||||
if(modfast) *modfast=mymodfast;
|
||||
return(OK);
|
||||
} else if (error==0) {
|
||||
} else {
|
||||
if(modfast) *modfast=mymodfast;
|
||||
return(E_EXISTS);
|
||||
} else {
|
||||
return(error);
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -311,9 +311,8 @@ URCunsetup(GENmodel *inModel, CKTcircuit *ckt)
|
|||
// assert(second && *second == -1)
|
||||
// assert(third && *third == NULL)
|
||||
modfast = CKTfndMod(ckt, &type, &modfast, varUid);
|
||||
error = modfast ? OK : E_NOMOD;
|
||||
if (error)
|
||||
return error;
|
||||
if (!modfast)
|
||||
return E_NOMOD;
|
||||
|
||||
for (in = modfast->GENinstances; in; in = in->GENnextInstance)
|
||||
CKTdltNNum(ckt, in->GENnode1);
|
||||
|
|
@ -331,9 +330,8 @@ URCunsetup(GENmodel *inModel, CKTcircuit *ckt)
|
|||
// assert(second && *second == -1)
|
||||
// assert(third && *third == NULL)
|
||||
modfast = CKTfndMod(ckt, &type, &modfast, varUid);
|
||||
error = modfast ? OK : E_NOMOD;
|
||||
if (error)
|
||||
return error;
|
||||
if (!modfast)
|
||||
return E_NOMOD;
|
||||
|
||||
CKTdltMod(ckt, modfast);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue