Simplify link-type checks in record supports

This commit is contained in:
Andrew Johnson
2016-06-02 22:22:11 -05:00
parent 7627454f63
commit d1986edd9e
9 changed files with 3 additions and 60 deletions

View File

@@ -109,10 +109,8 @@ static long init_record(aSubRecord *prec, int pass)
{
STATIC_ASSERT(sizeof(prec->onam)==sizeof(prec->snam));
GENFUNCPTR pfunc;
long status;
int i;
status = 0;
if (pass == 0) {
/* Allocate memory for arrays */
initFields(&prec->fta, &prec->noa, &prec->nea, NULL,
@@ -123,65 +121,20 @@ static long init_record(aSubRecord *prec, int pass)
}
/* Initialize the Subroutine Name Link */
switch (prec->subl.type) {
case CONSTANT:
if (prec->subl.type == CONSTANT) {
recGblInitConstantLink(&prec->subl, DBF_STRING, prec->snam);
break;
case PV_LINK:
case DB_LINK:
case CA_LINK:
break;
default:
recGblRecordError(S_db_badField, (void *)prec,
"aSubRecord(init_record) Bad SUBL link type");
return S_db_badField;
}
/* Initialize Input Links */
for (i = 0; i < NUM_ARGS; i++) {
struct link *plink = &(&prec->inpa)[i];
switch (plink->type) {
case CONSTANT:
if (plink->type == CONSTANT) {
if ((&prec->noa)[i] < 2)
recGblInitConstantLink(plink, (&prec->fta)[i], (&prec->a)[i]);
break;
case PV_LINK:
case CA_LINK:
case DB_LINK:
break;
default:
recGblRecordError(S_db_badField, (void *)prec,
"aSubRecord(init_record) Illegal INPUT LINK");
status = S_db_badField;
break;
}
}
if (status)
return status;
/* Initialize Output Links */
for (i = 0; i < NUM_ARGS; i++) {
switch ((&prec->outa)[i].type) {
case CONSTANT:
case PV_LINK:
case CA_LINK:
case DB_LINK:
break;
default:
recGblRecordError(S_db_badField, (void *)prec,
"aSubRecord(init_record) Illegal OUTPUT LINK");
status = S_db_badField;
}
}
if (status)
return status;
/* Call the user initialization routine if there is one */
if (prec->inam[0] != 0) {
pfunc = (GENFUNCPTR)registryFunctionFind(prec->inam);

View File

@@ -140,7 +140,6 @@ static long init_record(aaiRecord *prec, int pass)
return 0;
}
/* SIML must be a CONSTANT or a PV_LINK or a DB_LINK */
if (prec->siml.type == CONSTANT) {
recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
}

View File

@@ -140,7 +140,6 @@ static long init_record(aaoRecord *prec, int pass)
return 0;
}
/* SIML must be a CONSTANT or a PV_LINK or a DB_LINK */
if (prec->siml.type == CONSTANT) {
recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
}

View File

@@ -111,12 +111,10 @@ static long init_record(void *precord,int pass)
if (pass==0) return(0);
/* ai.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
if (prec->siml.type == CONSTANT) {
recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
}
/* ai.siol must be a CONSTANT or a PV_LINK or a DB_LINK */
if (prec->siol.type == CONSTANT) {
recGblInitConstantLink(&prec->siol,DBF_DOUBLE,&prec->sval);
}

View File

@@ -110,7 +110,6 @@ static long init_record(aoRecord *prec, int pass)
if (pass==0) return(0);
/* ao.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
if (prec->siml.type == CONSTANT) {
recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
}

View File

@@ -138,7 +138,6 @@ static long init_record(boRecord *prec,int pass)
if (pass==0) return(0);
/* bo.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
if (prec->siml.type == CONSTANT) {
recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
}

View File

@@ -103,12 +103,10 @@ static long init_record(longinRecord *prec, int pass)
if (pass==0) return(0);
/* longin.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
if (prec->siml.type == CONSTANT) {
recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
}
/* longin.siol must be a CONSTANT or a PV_LINK or a DB_LINK */
if (prec->siol.type == CONSTANT) {
recGblInitConstantLink(&prec->siol,DBF_LONG,&prec->sval);
}

View File

@@ -104,7 +104,6 @@ static long init_record(stringinRecord *prec, int pass)
recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
}
/* stringin.siol must be a CONSTANT or a PV_LINK or a DB_LINK */
if (prec->siol.type == CONSTANT) {
recGblInitConstantLink(&prec->siol,DBF_STRING,prec->sval);
}

View File

@@ -111,7 +111,6 @@ static long init_record(waveformRecord *prec, int pass)
return 0;
}
/* wf.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
if (prec->siml.type == CONSTANT) {
recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
}