From 17ca4ce1f1a0f462a9178e10fb166491c2f75987 Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 6 Aug 2011 19:10:16 +0000 Subject: [PATCH] fix use of possibly uninitialized variables, return on error --- ChangeLog | 4 ++ src/frontend/shyu.c | 102 +++++++++++++++++++++----------------------- 2 files changed, 52 insertions(+), 54 deletions(-) diff --git a/ChangeLog b/ChangeLog index f1613a6cb..9fa9730fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-08-06 Robert Larice + * src/frontend/shyu.c : + fix use of possibly uninitialized variables, return on error + 2011-08-06 Robert Larice * src/spicelib/devices/adms/admst/ngspice.xml : reposition NG_IGNOREABLE for non C99 compiler compatibility diff --git a/src/frontend/shyu.c b/src/frontend/shyu.c index e6ace15f5..823d99391 100644 --- a/src/frontend/shyu.c +++ b/src/frontend/shyu.c @@ -77,19 +77,18 @@ if_sens_run(CKTcircuit *ckt, wordlist *args, INPtables *tab) break; } } - if(which != -1) { - err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, "options", - &(ft_curckt->ci_specOpt), ft_curckt->ci_specTask); - if(err) { - ft_sperror(err,"createOptions"); - return(0);/* temporary */ - } - ft_curckt->ci_curOpt = ft_curckt->ci_specOpt; - } - else { + if(which == -1) { /* in DEEP trouble */ - ; + ft_sperror(err,"in DEEP trouble"); + return(0);/* temporary */ } + err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, "options", + &(ft_curckt->ci_specOpt), ft_curckt->ci_specTask); + if(err) { + ft_sperror(err,"createOptions"); + return(0);/* temporary */ + } + ft_curckt->ci_curOpt = ft_curckt->ci_specOpt; ft_curckt->ci_curTask = ft_curckt->ci_specTask; which = -1; for(j=0;jnumAnalyses;j++) { @@ -98,19 +97,17 @@ if_sens_run(CKTcircuit *ckt, wordlist *args, INPtables *tab) break; } } - if(which != -1) { - err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, "sense", - &(senseJob),ft_curckt->ci_specTask); - if(err) { - ft_sperror(err,"createSense"); - return(0);/* temporary */ - } - } - else{ + if(which == -1) { current->error = INPerrCat(current->error,INPmkTemp( "sensetivity analysis unsupported\n")); return(0); } + err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, "sense", + & senseJob, ft_curckt->ci_specTask); + if(err) { + ft_sperror(err,"createSense"); + return(0);/* temporary */ + } save = which; INPgetTok(&line,&token,1); if(strcmp(token ,"ac")==0){ @@ -122,17 +119,16 @@ if_sens_run(CKTcircuit *ckt, wordlist *args, INPtables *tab) break; } } - if(which != -1) { - err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, "acan", - &(acJob),ft_curckt->ci_specTask); - if(err) { - ft_sperror(err,"createAC"); /* or similar error message */ - return(0); - } - } - else{ + if(which == -1) { current->error = INPerrCat(current->error,INPmkTemp( "ac analysis unsupported\n")); + return(0);/* temporary */ + } + err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, "acan", + & acJob, ft_curckt->ci_specTask); + if(err) { + ft_sperror(err,"createAC"); /* or similar error message */ + return(0);/* temporary */ } INPgetTok(&line,&steptype,1); /* get DEC, OCT, or LIN */ @@ -165,14 +161,13 @@ if_sens_run(CKTcircuit *ckt, wordlist *args, INPtables *tab) if(which == -1) { current->error = INPerrCat(current->error,INPmkTemp( "DC operating point analysis unsupported\n")); + return(0);/* temporary */ } - else { - err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, "dcop", - &(opJob),ft_curckt->ci_specTask); - if(err) { - ft_sperror(err,"createOP"); /* or similar error message */ - return(0); - } + err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, "dcop", + & opJob, ft_curckt->ci_specTask); + if(err) { + ft_sperror(err,"createOP"); /* or similar error message */ + return(0); } } if(strcmp(token ,"dc")==0){ @@ -189,6 +184,7 @@ if_sens_run(CKTcircuit *ckt, wordlist *args, INPtables *tab) if(which==-1) { current->error = INPerrCat(current->error,INPmkTemp( "DC transfer curve analysis unsupported\n")); + return(0);/* temporary */ } err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, "DCtransfer", &(dcJob),ft_curckt->ci_specTask); @@ -237,17 +233,16 @@ if_sens_run(CKTcircuit *ckt, wordlist *args, INPtables *tab) break; } } - if(which != -1) { - err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, "tranan", - &(tranJob),ft_curckt->ci_specTask); - if(err) { - ft_sperror(err,"createTRAN"); - return(0); - } - } - else{ + if(which == -1) { current->error = INPerrCat(current->error,INPmkTemp( "transient analysis unsupported\n")); + return(0);/* temporary */ + } + err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, "tranan", + & tranJob, ft_curckt->ci_specTask); + if(err) { + ft_sperror(err,"createTRAN"); + return(0); } parm=INPgetValue(ckt,&line,IF_REAL,tab);/* Tstep */ @@ -297,17 +292,16 @@ uic: break; } } - if(which != -1) { - err = (*(ft_sim->newAnalysis))(ft_curckt->ci_ckt,which,"pssan", - &(pssJob),ft_curckt->ci_specTask); - if(err) { - ft_sperror(err,"createPSS"); - return(0); - } - } - else{ + if(which == -1) { current->error = INPerrCat(current->error,INPmkTemp( "periodic steady state analysis unsupported\n")); + return(0);/* temporary */ + } + err = ft_sim->newAnalysis (ft_curckt->ci_ckt,which, "pssan", + & pssJob, ft_curckt->ci_specTask); + if(err) { + ft_sperror(err,"createPSS"); + return(0); } parm=INPgetValue(ckt,&line,IF_REAL,tab);/* Guessed Frequency */