Nr 5/5 (x = ...) == NULL , swallow warnings

This commit is contained in:
rlar 2010-11-19 18:54:40 +00:00
parent e6c30efe46
commit 05441d5823
54 changed files with 112 additions and 108 deletions

View File

@ -1,3 +1,7 @@
2010-11-19 Robert Larice
* */** :
Nr 5/5 (x = ...) == NULL , swallow warnings
2010-11-19 Robert Larice
* */** :
Nr 4/5 (x = ...) != NULL , swallow warnings

View File

@ -25,9 +25,9 @@ LOGmakeEntry(char *name, char *description)
* without stepping on each other.
*/
#ifdef ultrix
if (!(fpLog = fopen(LogFileName, "A"))) {
if ((fpLog = fopen(LogFileName, "A")) == NULL) {
#else
if (!(fpLog = fopen(LogFileName, "a"))) {
if ((fpLog = fopen(LogFileName, "a")) == NULL) {
#endif
if (!LogError)
perror(LogFileName);

View File

@ -23,7 +23,7 @@ readAsciiData( char *fileName, int impType, DOPtable **ppTable )
double sign;
/* Open Input File */
if (!(fpAscii = fopen( fileName, "r" ))) {
if ((fpAscii = fopen( fileName, "r" )) == NULL) {
perror( fileName );
exit(-1);
}

View File

@ -45,7 +45,7 @@ SUPbinRead(char *inFile, float *x, float *conc, int *impId, int *numNod)
}
/* Open Input File */
if (!(fpSuprem = fopen( inFile, "r" ))) {
if ((fpSuprem = fopen( inFile, "r" )) == NULL) {
perror(inFile);
return;
}
@ -240,7 +240,7 @@ SUPascRead(char *inFile, float *x, float *conc, int *impId, int *numNod)
}
/* Open Input File */
if (!(fpSuprem = fopen( inFile, "r" ))) {
if ((fpSuprem = fopen( inFile, "r" )) == NULL) {
perror(inFile);
return;
}

View File

@ -371,7 +371,7 @@ com_rspice(wordlist *wl)
fputs(buf, cp_out);
}
outfile = smktemp("rsp");
if (!(out = fopen(outfile, "w+"))) {
if ((out = fopen(outfile, "w+")) == NULL) {
perror(outfile);
(void) fclose(serv);
return;

View File

@ -127,11 +127,11 @@ com_compose(wordlist *wl)
if (eq(wl->wl_word, "values")) {
/* Build up the vector from the rest of the line... */
wl = wl->wl_next;
if (!(pn = ft_getpnames(wl, TRUE)))
if ((pn = ft_getpnames(wl, TRUE)) == NULL)
return;
first_pn = pn;
while (pn) {
if (!(v = ft_evaluate(pn)))
if ((v = ft_evaluate(pn)) == NULL)
return;
if (!vecs)
vecs = lv = v;
@ -260,7 +260,7 @@ com_compose(wordlist *wl)
}
if (cieq(var, "start")) {
startgiven = TRUE;
if (!(td = ft_numparse(&val, FALSE))) {
if ((td = ft_numparse(&val, FALSE)) == NULL) {
fprintf(cp_err,
"Error: bad parm %s = %s\n",
var, val);
@ -269,7 +269,7 @@ com_compose(wordlist *wl)
start = *td;
} else if (cieq(var, "stop")) {
stopgiven = TRUE;
if (!(td = ft_numparse(&val, FALSE))) {
if ((td = ft_numparse(&val, FALSE)) == NULL) {
fprintf(cp_err,
"Error: bad parm %s = %s\n",
var, val);
@ -278,7 +278,7 @@ com_compose(wordlist *wl)
stop = *td;
} else if (cieq(var, "step")) {
stepgiven = TRUE;
if (!(td = ft_numparse(&val, FALSE))) {
if ((td = ft_numparse(&val, FALSE)) == NULL) {
fprintf(cp_err,
"Error: bad parm %s = %s\n",
var, val);
@ -287,7 +287,7 @@ com_compose(wordlist *wl)
step = *td;
} else if (cieq(var, "center")) {
centergiven = TRUE;
if (!(td = ft_numparse(&val, FALSE))) {
if ((td = ft_numparse(&val, FALSE)) == NULL) {
fprintf(cp_err,
"Error: bad parm %s = %s\n",
var, val);
@ -296,7 +296,7 @@ com_compose(wordlist *wl)
center = *td;
} else if (cieq(var, "span")) {
spangiven = TRUE;
if (!(td = ft_numparse(&val, FALSE))) {
if ((td = ft_numparse(&val, FALSE)) == NULL) {
fprintf(cp_err,
"Error: bad parm %s = %s\n",
var, val);
@ -305,7 +305,7 @@ com_compose(wordlist *wl)
span = *td;
} else if (cieq(var, "mean")) {
meangiven = TRUE;
if (!(td = ft_numparse(&val, FALSE))) {
if ((td = ft_numparse(&val, FALSE)) == NULL) {
fprintf(cp_err,
"Error: bad parm %s = %s\n",
var, val);
@ -314,7 +314,7 @@ com_compose(wordlist *wl)
mean = *td;
} else if (cieq(var, "sd")) {
sdgiven = TRUE;
if (!(td = ft_numparse(&val, FALSE))) {
if ((td = ft_numparse(&val, FALSE)) == NULL) {
fprintf(cp_err,
"Error: bad parm %s = %s\n",
var, val);
@ -323,7 +323,7 @@ com_compose(wordlist *wl)
sd = *td;
} else if (cieq(var, "lin")) {
lingiven = TRUE;
if (!(td = ft_numparse(&val, FALSE))) {
if ((td = ft_numparse(&val, FALSE)) == NULL) {
fprintf(cp_err,
"Error: bad parm %s = %s\n",
var, val);
@ -332,7 +332,7 @@ com_compose(wordlist *wl)
lin = *td;
} else if (cieq(var, "log")) {
loggiven = TRUE;
if (!(td = ft_numparse(&val, FALSE))) {
if ((td = ft_numparse(&val, FALSE)) == NULL) {
fprintf(cp_err,
"Error: bad parm %s = %s\n",
var, val);
@ -341,7 +341,7 @@ com_compose(wordlist *wl)
log = *td;
} else if (cieq(var, "dec")) {
decgiven = TRUE;
if (!(td = ft_numparse(&val, FALSE))) {
if ((td = ft_numparse(&val, FALSE)) == NULL) {
fprintf(cp_err,
"Error: bad parm %s = %s\n",
var, val);
@ -350,7 +350,7 @@ com_compose(wordlist *wl)
dec = *td;
} else if (cieq(var, "gauss")) {
gaussgiven = TRUE;
if (!(td = ft_numparse(&val, FALSE))) {
if ((td = ft_numparse(&val, FALSE)) == NULL) {
fprintf(cp_err,
"Error: bad parm %s = %s\n",
var, val);
@ -359,7 +359,7 @@ com_compose(wordlist *wl)
gauss = *td;
} else if (cieq(var, "random")) {
randmgiven = TRUE;
if (!(td = ft_numparse(&val, FALSE))) {
if ((td = ft_numparse(&val, FALSE)) == NULL) {
fprintf(cp_err,
"Error: bad parm %s = %s\n",
var, val);

View File

@ -30,7 +30,7 @@ com_ghelp(wordlist *wl)
com_help(wl);
return;
}
if (!(npath = cp_tildexpand(path))) {
if ((npath = cp_tildexpand(path)) == NULL) {
fprintf(cp_err, "Note: can't find help dir %s\n", path);
fprintf(cp_err, "Defaulting to old help.\n\n");
com_help(wl);

View File

@ -1021,7 +1021,7 @@ static int measure_parse_stdParams (
if( strcasecmp(pValue,"LAST")==0) {
engVal1 = MEASURE_LAST_TRANSITION;
} else {
if (!(engVal = ft_numparse(&pValue, FALSE))) {
if ((engVal = ft_numparse(&pValue, FALSE)) == NULL) {
sprintf(errbuf,"bad syntax of ??\n");
return 0;
}
@ -1127,7 +1127,7 @@ static int measure_parse_find (
}
if (strcasecmp(pName,"AT")==0) {
if (!(engVal = ft_numparse(&pVal, FALSE))) {
if ((engVal = ft_numparse(&pVal, FALSE)) == NULL) {
sprintf(errbuf,"bad syntax of WHEN\n");
return 0;
}

View File

@ -175,7 +175,7 @@ docommand(wordlist *wlist)
if (eq(wlist->wl_word, noredirect[i]))
break;
if (!noredirect[i]) {
if (!(wlist = cp_redirect(wlist))) {
if ((wlist = cp_redirect(wlist)) == NULL) {
cp_ioreset();
return;
}

View File

@ -144,7 +144,7 @@ ft_cpinit(void)
for (x = ft_setkwords; *x; x++)
cp_addkword(CT_VARIABLES, *x);
for (i = 0; ; i++) {
if (!(s = ft_typenames(i)))
if ((s = ft_typenames(i)) == NULL)
break;
cp_addkword(CT_TYPENAMES, s);
}

View File

@ -99,7 +99,7 @@ com_define(wordlist *wlist)
/* Parse the rest of it. We can't know if there are the right
* number of undefined variables in the expression.
*/
if (!(pn = ft_getpnames(wl, FALSE)))
if ((pn = ft_getpnames(wl, FALSE)) == NULL)
return;
/* This is a pain -- when things are garbage-collected, any

View File

@ -113,7 +113,7 @@ ft_savedotargs(void)
(void) gettok(&s);
name = gettok(&s);
if (!(w = gettoks(s))) {
if ((w = gettoks(s)) == NULL) {
fprintf(cp_err, "Warning: no nodes given: %s\n", iline->wl_word);
} else {
if (isaplot) {
@ -138,7 +138,7 @@ ft_savedotargs(void)
} else if (ciprefix(".four", s)) {
(void) gettok(&s);
(void) gettok(&s);
if (!(w = gettoks(s)))
if ((w = gettoks(s)) == NULL)
fprintf(cp_err, "Warning: no nodes given: %s\n", iline->wl_word);
else {
some = 1;

View File

@ -77,7 +77,7 @@ fourier(wordlist *wl, struct plot *current_plot)
return 1;
}
s = wl->wl_word;
if (!(ff = ft_numparse(&s, FALSE)) || (*ff <= 0.0)) {
if ((ff = ft_numparse(&s, FALSE)) == NULL || (*ff <= 0.0)) {
fprintf(cp_err, "Error: bad fund freq %s\n", wl->wl_word);
return 1;
}

View File

@ -30,13 +30,13 @@ hlp_main(char *path, wordlist *wl)
if (wl) {
while (wl) {
if (!(place = findglobalsubject(wl->wl_word))) {
if ((place = findglobalsubject(wl->wl_word)) == NULL) {
fprintf(stderr, "Error: No such topic: %s\n",
wl->wl_word);
wl = wl->wl_next;
continue;
}
if (!(top = hlp_read(place))) {
if ((top = hlp_read(place)) == NULL) {
fprintf(stderr, "Error: can't read topic\n");
wl = wl->wl_next;
continue;
@ -45,11 +45,11 @@ hlp_main(char *path, wordlist *wl)
wl = wl->wl_next;
}
} else {
if (!(place = findglobalsubject("main"))) {
if ((place = findglobalsubject("main")) == NULL) {
fprintf(stderr, "Error: no main topic\n");
return;
}
if (!(top = hlp_read(place))) {
if ((top = hlp_read(place)) == NULL) {
fprintf(stderr, "Error: can't read topic\n");
return;
}
@ -120,7 +120,7 @@ FILE *hlp_fopen(char *filename)
strcat(buf, filename);
strcat(buf, ".txt");
hlp_pathfix(buf);
if (!(hlp_ftable[hlp_ftablesize].fp = fopen(buf, "r"))) {
if ((hlp_ftable[hlp_ftablesize].fp = fopen(buf, "r")) == NULL) {
perror(buf);
return (NULL);
}

View File

@ -67,7 +67,7 @@ hlp_provide(topic *top)
/* Create a new window... */
if (hlp_usex)
hlp_xwait(parent, TRUE);
if (!(newtop = hlp_read(res->place))) {
if ((newtop = hlp_read(res->place)) == NULL) {
fprintf(stderr, "Internal error: bad link\n");
hlp_xwait(parent, FALSE);
continue;

View File

@ -249,7 +249,7 @@ findsubject(char *filename, char *subject)
/* open up index for filename */
sprintf(buf, "%s%s%s.idx", hlp_directory, DIR_PATHSEP, filename);
hlp_pathfix(buf);
if (!(fp = fopen(buf, "rb"))) {
if ((fp = fopen(buf, "rb")) == NULL) {
perror(buf);
return(-1);
}
@ -264,7 +264,7 @@ findsubject(char *filename, char *subject)
fclose(fp);
if (!(fp = fopen(buf, "rb"))) {
if ((fp = fopen(buf, "rb")) == NULL) {
perror(buf);
return(-1);
}
@ -279,7 +279,7 @@ findsubject(char *filename, char *subject)
fclose(fp);
if (!(fp = fopen(buf, "rb"))) {
if ((fp = fopen(buf, "rb")) == NULL) {
perror(buf);
return(-1);
}

View File

@ -118,7 +118,7 @@ GRAPH *graph)
hcopygraphid = graph->graphid;
if (!(plotfile = fopen((char*) graph->devdep, "w"))) {
if ((plotfile = fopen((char*) graph->devdep, "w")) == NULL) {
perror((char*) graph->devdep);
graph->devdep = NULL;
return(1);

View File

@ -945,7 +945,7 @@ com_edit(wordlist *wl)
cp_interactive = inter;
return;
}
if (!(fp = inp_pathopen(wl->wl_word, "r"))) {
if ((fp = inp_pathopen(wl->wl_word, "r")) == NULL) {
perror(wl->wl_word);
cp_interactive = inter;
return;
@ -961,7 +961,7 @@ com_edit(wordlist *wl)
permfile = FALSE;
}
if (ft_curckt && !ft_curckt->ci_filename) {
if (!(fp = fopen(filename, "w"))) {
if ((fp = fopen(filename, "w")) == NULL) {
perror(filename);
cp_interactive = inter;
return;
@ -973,7 +973,7 @@ com_edit(wordlist *wl)
"circuit not saved\n");
fclose(fp);
} else if (!ft_curckt) {
if (!(fp = fopen(filename, "w"))) {
if ((fp = fopen(filename, "w")) == NULL) {
perror(filename);
cp_interactive = inter;
return;
@ -986,7 +986,7 @@ com_edit(wordlist *wl)
return;
}
if (!(fp = fopen(filename, "r"))) {
if ((fp = fopen(filename, "r")) == NULL) {
perror(filename);
cp_interactive = inter;
return;
@ -1023,7 +1023,7 @@ doedit(char *filename)
if (cp_getvar("editor", CP_STRING, buf2)) {
editor = buf2;
} else {
if (!(editor = getenv("EDITOR"))) {
if ((editor = getenv("EDITOR")) == NULL) {
if (Def_Editor && *Def_Editor)
editor = Def_Editor;
else
@ -1050,13 +1050,13 @@ com_source(wordlist *wl)
if (wl->wl_next) {
/* There are several files -- put them into a temp file */
tempfile = smktemp("sp");
if (!(fp = inp_pathopen(tempfile, "w+"))) {
if ((fp = inp_pathopen(tempfile, "w+")) == NULL) {
perror(tempfile);
cp_interactive = TRUE;
return;
}
while (wl) {
if (!(tp = inp_pathopen(wl->wl_word, "r"))) {
if ((tp = inp_pathopen(wl->wl_word, "r")) == NULL) {
perror(wl->wl_word);
fclose(fp);
cp_interactive = TRUE;

View File

@ -139,7 +139,7 @@ readline(FILE *fd)
strlen++;
if( strlen >= memlen ) {
memlen += STRGROW;
if( !(strptr = TREALLOC(char, strptr, memlen + 1))) {
if((strptr = TREALLOC(char, strptr, memlen + 1)) == NULL) {
return (NULL);
}
}
@ -1232,9 +1232,9 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c
if ( dir_name != NULL ) sprintf( big_buff2, "%s/%s", dir_name, s );
else sprintf( big_buff2, "./%s", s );
dir_name_flag = FALSE;
if ( !( newfp = inp_pathopen( s, "r" ) ) ) {
if ((newfp = inp_pathopen( s, "r" )) == NULL) {
dir_name_flag = TRUE;
if ( !( newfp = inp_pathopen( big_buff2, "r" ) ) ) {
if ((newfp = inp_pathopen( big_buff2, "r" )) == NULL ) {
perror(s);
if(copys) tfree(copys); /* allocated by the cp_tildexpand() above */
tfree(buffer); /* allocated by readline() above */
@ -1290,9 +1290,9 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c
if ( dir_name != NULL ) sprintf( big_buff2, "%s/%s", dir_name, s );
else sprintf( big_buff2, "./%s", s );
dir_name_flag = FALSE;
if (!(newfp = inp_pathopen(s, "r"))) {
if ((newfp = inp_pathopen(s, "r")) == NULL) {
dir_name_flag = TRUE;
if ( !( newfp = inp_pathopen( big_buff2, "r" ) ) ) {
if ((newfp = inp_pathopen( big_buff2, "r" )) == NULL ) {
perror(s);
if(copys) {
tfree(copys); /* allocated by the cp_tildexpand() above */

View File

@ -212,13 +212,13 @@ nutcom_source(wordlist *wl)
if (wl->wl_next) {
/* There are several files -- put them into a temp file... */
tempfile = smktemp("sp");
if (!(fp = inp_pathopen(tempfile, "w+"))) {
if ((fp = inp_pathopen(tempfile, "w+")) == NULL) {
perror(tempfile);
cp_interactive = TRUE;
return;
}
while (wl) {
if (!(tp = inp_pathopen(wl->wl_word, "r"))) {
if ((tp = inp_pathopen(wl->wl_word, "r")) == NULL) {
perror(wl->wl_word);
(void) fclose(fp);
cp_interactive = TRUE;

View File

@ -1091,14 +1091,14 @@ name_eq(char *n1, char *n2)
if ((s =strchr(n1, '(')) != NULL) {
strcpy(buf1, s);
if (!(s =strchr(buf1, ')')))
if ((s =strchr(buf1, ')')) == NULL)
return FALSE;
*s = '\0';
n1 = buf1;
}
if ((s =strchr(n2, '(')) != NULL) {
strcpy(buf2, s);
if (!(s =strchr(buf2, ')')))
if ((s =strchr(buf2, ')')) == NULL)
return FALSE;
*s = '\0';
n2 = buf2;

View File

@ -48,7 +48,7 @@ loop: s =strchr(t, cp_back);
/* What the heck, let "echo `foo" work... */
*s = '\0';
t++; /* Get past the second ` */
if (!(nwl = backeval(buf))) {
if ((nwl = backeval(buf)) == NULL) {
wlist->wl_word = NULL;
return (wlist);
}

View File

@ -89,7 +89,7 @@ ft_gnuplot(double *xlims, double *ylims, char *filename, char *title, char *xlab
}
/* Open the output gnuplot file. */
if (!(file = fopen(filename_plt, "w"))) {
if ((file = fopen(filename_plt, "w")) == NULL) {
perror(filename);
return;
}
@ -161,7 +161,7 @@ ft_gnuplot(double *xlims, double *ylims, char *filename, char *title, char *xlab
}
/* Open the output gnuplot data file. */
if (!(file_data = fopen(filename_data, "w"))) {
if ((file_data = fopen(filename_data, "w")) == NULL) {
perror(filename);
return;
}
@ -255,7 +255,7 @@ ft_writesimple(double *xlims, double *ylims, char *filename, char *title, char *
}
/* Open the output data file. */
if (!(file_data = fopen(filename_data, "w"))) {
if ((file_data = fopen(filename_data, "w")) == NULL) {
perror(filename);
return;
}

View File

@ -85,7 +85,7 @@ gr_init(double *xlims, double *ylims, /* The size of the screen. */
NG_IGNORE(nplots);
if (!(graph = NewGraph())) {
if ((graph = NewGraph()) == NULL) {
return(FALSE);
}

View File

@ -61,7 +61,7 @@ GRAPH *NewGraph(void)
LISTGRAPH *list;
int BucketId = RunningId % NUMGBUCKETS;
if (!(list = NEWLISTGRAPH)) {
if ((list = NEWLISTGRAPH) == NULL) {
internalerror("can't allocate a listgraph");
return((GRAPH *) NULL);
}

View File

@ -40,7 +40,7 @@ int
Plt5_NewViewport(GRAPH *graph)
{
if (!(plotfile = fopen((char*) graph->devdep, "w"))) {
if ((plotfile = fopen((char*) graph->devdep, "w")) == NULL) {
graph->devdep = NULL;
perror((char*) graph->devdep);
return(1);

View File

@ -573,7 +573,7 @@ plotit(wordlist *wl, char *hcopy, char *devname)
fprintf(cp_err, "Error: misplaced vs arg\n");
goto quit;
} else {
if (!(n = n->pn_next)) {
if ((n = n->pn_next) == NULL) {
fprintf(cp_err,
"Error: missing vs arg\n");
goto quit;

View File

@ -80,7 +80,7 @@ ft_xgraph(double *xlims, double *ylims, char *filename, char *title, char *xlabe
}
/* Open the output file. */
if (!(file = fopen(filename, "w"))) {
if ((file = fopen(filename, "w")) == NULL) {
perror(filename);
return;
}

View File

@ -94,7 +94,7 @@ com_print(wordlist *wl)
ngood = 0;
for (nn = ft_getpnames(wl, TRUE); nn; nn = nn->pn_next) {
if (!(v = ft_evaluate(nn)))
if ((v = ft_evaluate(nn)) == NULL)
continue;
if (!vecs)
vecs = lv = v;
@ -710,7 +710,7 @@ com_cross(wordlist *wl)
newvec = wl->wl_word;
wl = wl->wl_next;
s = wl->wl_word;
if (!(d = ft_numparse(&s, FALSE))) {
if ((d = ft_numparse(&s, FALSE)) == NULL) {
fprintf(cp_err, "Error: bad number %s\n", wl->wl_word);
return;
}
@ -721,7 +721,7 @@ com_cross(wordlist *wl)
wl = wl->wl_next;
pn = ft_getpnames(wl, TRUE);
while (pn) {
if (!(n = ft_evaluate(pn)))
if ((n = ft_evaluate(pn)) == NULL)
return;
if (!vecs)
vecs = lv = n;
@ -912,7 +912,7 @@ com_splot(wordlist *wl)
return;
}
t = buf;
if (!(s = gettok(&t)))
if ((s = gettok(&t)) == NULL)
return;
plot_setcur(s);

View File

@ -168,7 +168,7 @@ PS_NewViewport(GRAPH *graph)
int x1,x2,y1,y2;
hcopygraphid = graph->graphid;
/* devdep initially contains name of output file */
if (!(plotfile = fopen((char*)graph->devdep, "w"))) {
if ((plotfile = fopen((char*)graph->devdep, "w")) == NULL) {
perror((char*)graph->devdep);
graph->devdep = NULL;
return(1);

View File

@ -64,14 +64,14 @@ raw_write(char *name, struct plot *pl, bool app, bool binary)
#if defined(__MINGW32__) || defined(_MSC_VER)
/* - Binary file binary write - hvogt 15.03.2000 ---------------------*/
if (binary) {
if (!(fp = fopen(name, app ? "ab" : "wb"))) {
if ((fp = fopen(name, app ? "ab" : "wb")) == NULL) {
perror(name);
return;
}
fprintf(cp_out,"binary raw file\n");
}
else {
if (!(fp = fopen(name, app ? "a" : "w"))) {
if ((fp = fopen(name, app ? "a" : "w")) == NULL) {
perror(name);
return;
}
@ -297,7 +297,7 @@ raw_read(char *name)
bool binary = TRUE;
#endif
if (!(fp = fopen(name, "r"))) {
if ((fp = fopen(name, "r")) == NULL) {
perror(name);
return (NULL);
}
@ -315,7 +315,7 @@ raw_read(char *name)
if (binary) {
(void) fclose(fp);
if (!(fp = fopen(name, "rb"))) {
if ((fp = fopen(name, "rb")) == NULL) {
perror(name);
return (NULL);
}
@ -794,7 +794,7 @@ spar_write(char *name, struct plot *pl, double Rbaseval)
}*/
}
if (!(fp = fopen(name, "w"))) {
if ((fp = fopen(name, "w")) == NULL) {
perror(name);
return;
}

View File

@ -251,7 +251,7 @@ dosim(
#if defined(__MINGW32__) || defined(_MSC_VER)
/* ask if binary or ASCII, open file with wb or w */
else if (ascii) {
if(!(rawfileFp = fopen(wl->wl_word, "w"))) {
if((rawfileFp = fopen(wl->wl_word, "w")) == NULL) {
perror(wl->wl_word);
ft_setflag = FALSE;
return 1;
@ -259,7 +259,7 @@ dosim(
fprintf(cp_out,"ASCII raw file\n");
}
else if (!ascii) {
if(!(rawfileFp = fopen(wl->wl_word, "wb"))) {
if((rawfileFp = fopen(wl->wl_word, "wb")) == NULL) {
perror(wl->wl_word);
ft_setflag = FALSE;
return 1;

View File

@ -102,7 +102,7 @@ com_resume(wordlist *wl)
#if defined(__MINGW32__) || defined(_MSC_VER)
/* ask if binary or ASCII, open file with w or wb hvogt 15.3.2000 */
else if (ascii) {
if(!(rawfileFp = fopen(last_used_rawfile, "a"))) {
if((rawfileFp = fopen(last_used_rawfile, "a")) == NULL) {
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
perror(last_used_rawfile);
ft_setflag = FALSE;
@ -110,7 +110,7 @@ com_resume(wordlist *wl)
}
}
else if (!ascii) {
if(!(rawfileFp = fopen(last_used_rawfile, "ab"))) {
if((rawfileFp = fopen(last_used_rawfile, "ab")) == NULL) {
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
perror(last_used_rawfile);
ft_setflag = FALSE;

View File

@ -43,21 +43,21 @@ com_spec(wordlist *wl)
}
s = wl->wl_word;
tlen = (plot_cur->pl_scale)->v_length;
if (!(freq = ft_numparse(&s, FALSE)) || (*freq < 0.0)) {
if ((freq = ft_numparse(&s, FALSE)) == NULL || (*freq < 0.0)) {
fprintf(cp_err, "Error: bad start freq %s\n", wl->wl_word);
return;
}
startf = *freq;
wl = wl->wl_next;
s = wl->wl_word;
if (!(freq = ft_numparse(&s, FALSE)) || (*freq <= startf)) {
if ((freq = ft_numparse(&s, FALSE)) == NULL || (*freq <= startf)) {
fprintf(cp_err, "Error: bad stop freq %s\n", wl->wl_word);
return;
}
stopf = *freq;
wl = wl->wl_next;
s = wl->wl_word;
if (!(freq = ft_numparse(&s, FALSE)) || !(*freq <= (stopf-startf))) {
if ((freq = ft_numparse(&s, FALSE)) == NULL || !(*freq <= (stopf-startf))) {
fprintf(cp_err, "Error: bad step freq %s\n", wl->wl_word);
return;
}

View File

@ -523,7 +523,7 @@ doit(struct line *deck)
/* Otherwise, expand sub-subcircuits recursively. */
for (ks = sss = subs; sss; sss = sss->su_next) /* iterate through the list of subcircuits */
if (!(sss->su_def = doit(sss->su_def)))
if ((sss->su_def = doit(sss->su_def)) == NULL)
return (NULL);
subs = ks; /* ks has held pointer to start of subcircuits list. */
@ -904,7 +904,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, char *sub
paren_ptr++;
name = paren_ptr;
if ( !( paren_ptr = strstr( paren_ptr, ")" ) ) ) {
if ( ( paren_ptr = strstr( paren_ptr, ")" ) ) == NULL) {
*(name-1) = '(';
fprintf(cp_err, "Error: missing closing ')' for .ic|.nodeset statement %s\n", c->li_line);
goto quit;

View File

@ -223,7 +223,7 @@ com_stype(wordlist *wl)
char *s;
for (tt = 0; ; tt++) {
if (!(s = ft_typenames(tt)) || eq(type, s))
if ((s = ft_typenames(tt)) == NULL || eq(type, s))
break;
}
if (!s) {

View File

@ -695,7 +695,7 @@ cp_variablesubst(wordlist *wlist)
}
(void) strcpy(tbuf, t); /* MW. Save t*/
if (!(wl = wl_splice(wl, nwl))) {/*CDHW this frees wl CDHW*/
if ((wl = wl_splice(wl, nwl)) == NULL) {/*CDHW this frees wl CDHW*/
wl_free(nwl);
return (NULL);
}

View File

@ -259,7 +259,7 @@ plot_add(struct plot *pl)
cp_addkword(CT_VECTOR, v->v_name);
cp_addkword(CT_VECTOR, "all");
if (!(s = ft_plotabbrev(pl->pl_name)))
if ((s = ft_plotabbrev(pl->pl_name)) == NULL)
s = "unknown";
do {
(void) sprintf(buf, "%s%d", s, plot_num);
@ -694,7 +694,7 @@ plot_alloc(char *name)
char buf[BSIZE_SP];
ZERO(pl, struct plot);
if (!(s = ft_plotabbrev(name)))
if ((s = ft_plotabbrev(name)) == NULL)
s = "unknown";
do {
(void) sprintf(buf, "%s%d", s, plot_num);

View File

@ -40,18 +40,18 @@ void * hrealloc(void *ptr, size_t num);
#ifdef CIDER
#define RALLOC(ptr,type,number) \
if ((number) && !(ptr = (type *)calloc((size_t)(number), sizeof(type)))) { \
if ((number) && (ptr = (type *)calloc((size_t)(number), sizeof(type))) == NULL) { \
return(E_NOMEM); \
}
#define XALLOC(ptr,type,number) \
if ((number) && !(ptr = (type *)calloc((size_t)(number), sizeof(type)))) { \
if ((number) && (ptr = (type *)calloc((size_t)(number), sizeof(type))) == NULL) { \
SPfrontEnd->IFerror( E_PANIC, "Out of Memory", NIL(IFuid) ); \
exit( 1 ); \
}
#define XCALLOC(ptr,type,number) \
if ((number) && !(ptr = (type *)calloc((size_t)(number), sizeof(type)))) { \
if ((number) && (ptr = (type *)calloc((size_t)(number), sizeof(type))) == NULL) { \
fprintf( stderr, "Out of Memory\n" ); \
exit( 1 ); \
}

View File

@ -899,7 +899,7 @@ main(int argc, char **argv)
case 'c': /* Circuit file */
if (optarg) {
if (!(circuit_file = fopen(optarg, "r"))) {
if ((circuit_file = fopen(optarg, "r")) == NULL) {
perror(optarg);
sp_shutdown(EXIT_BAD);
}
@ -972,7 +972,7 @@ main(int argc, char **argv)
/* Open the log file */
#ifdef HAS_WINDOWS
/* flogp used by winmain's putc which writes to file 'buf' */
if (!(flogp = fopen(buf, "w"))) {
if ((flogp = fopen(buf, "w")) == NULL) {
#else
/* Connect stdout to file buf and log stdout */
if (!(freopen (buf, "w", stdout))) {

View File

@ -18,7 +18,7 @@ Author: 1985 Thomas L. Quarles
#define CKALLOC(var,size,type) \
if(size && (!(var = TMALLOC(type, size)))){\
if(size && ((var = TMALLOC(type, size)) == NULL)){\
return(E_NOMEM);\
}

View File

@ -69,7 +69,7 @@ NBJTdump(GENmodel *inModel, CKTcircuit *ckt)
anyOutput = 1;
sprintf(fileName, "%s%s.%d.%s", output->OUTProotFile, prefix,
*state_num, inst->NBJTname);
if (!(fpState = fopen(fileName, "w"))) {
if ((fpState = fopen(fileName, "w")) == NULL) {
perror(fileName);
} else {
NBJTputHeader(fpState, ckt, inst);

View File

@ -18,7 +18,7 @@ Author: 1987 Kartikeya Mayaram, U. C. Berkeley CAD Group
#define NIL(type) ((type *)0)
#define TSCALLOC(var, size, type)\
if (size && (!(var =(type *)calloc(1, (unsigned)(size)*sizeof(type))))) {\
if (size && (var =(type *)calloc(1, (unsigned)(size)*sizeof(type))) == NULL) {\
return(E_NOMEM);\
}

View File

@ -70,7 +70,7 @@ NBJT2dump(GENmodel *inModel, CKTcircuit *ckt)
anyOutput = 1;
sprintf(fileName, "%s%s.%d.%s", output->OUTProotFile, prefix,
*state_num, inst->NBJT2name);
if (!(fpState = fopen(fileName, "w"))) {
if ((fpState = fopen(fileName, "w")) == NULL) {
perror(fileName);
} else {
NBJT2putHeader(fpState, ckt, inst);

View File

@ -20,7 +20,7 @@ $Id$
#define NIL(type) ((type *)0)
#define TSCALLOC(var, size, type)\
if (size && (!(var =(type *)calloc(1, (unsigned)(size)*sizeof(type))))) {\
if (size && (var = (type *)calloc(1, (unsigned)(size)*sizeof(type))) == NULL) {\
return(E_NOMEM);\
}

View File

@ -15,7 +15,7 @@ University of Science and Technology of China
#define NIL(type) ((type *)0)
#define TSCALLOC(var, size, type)\
if (size && (!(var =(type *)calloc(1, (unsigned)(size)*sizeof(type))))) {\
if (size && (var =(type *)calloc(1, (unsigned)(size)*sizeof(type))) == NULL) {\
return(E_NOMEM);\
}

View File

@ -69,7 +69,7 @@ NUMDdump(GENmodel *inModel, CKTcircuit *ckt)
anyOutput = 1;
sprintf(fileName, "%s%s.%d.%s", output->OUTProotFile, prefix,
*state_num, inst->NUMDname);
if (!(fpState = fopen(fileName, "w"))) {
if ((fpState = fopen(fileName, "w")) == NULL) {
perror(fileName);
} else {
NUMDputHeader(fpState, ckt, inst);

View File

@ -18,7 +18,7 @@ Author: 1987 Kartikeya Mayaram, U. C. Berkeley CAD Group
#define NIL(type) ((type *)0)
#define TSCALLOC(var, size, type)\
if (size && (!(var =(type *)calloc(1, (unsigned)(size)*sizeof(type))))) {\
if (size && (var =(type *)calloc(1, (unsigned)(size)*sizeof(type))) == NULL) {\
return(E_NOMEM);\
}

View File

@ -70,7 +70,7 @@ NUMD2dump(GENmodel *inModel, CKTcircuit *ckt)
anyOutput = 1;
sprintf(fileName, "%s%s.%d.%s", output->OUTProotFile, prefix,
*state_num, inst->NUMD2name);
if (!(fpState = fopen(fileName, "w"))) {
if ((fpState = fopen(fileName, "w")) == NULL) {
perror(fileName);
} else {
NUMD2putHeader(fpState, ckt, inst);

View File

@ -20,7 +20,7 @@ $Id$
#define NIL(type) ((type *)0)
#define TSCALLOC(var, size, type)\
if (size && (!(var =(type *)calloc(1, (unsigned)(size)*sizeof(type))))) {\
if (size && (var =(type *)calloc(1, (unsigned)(size)*sizeof(type))) == NULL) {\
return(E_NOMEM);\
}

View File

@ -70,7 +70,7 @@ NUMOSdump(GENmodel *inModel, CKTcircuit *ckt)
anyOutput = 1;
sprintf(fileName, "%s%s.%d.%s", output->OUTProotFile, prefix,
*state_num, inst->NUMOSname);
if (!(fpState = fopen(fileName, "w"))) {
if ((fpState = fopen(fileName, "w")) == NULL) {
perror(fileName);
} else {
NUMOSputHeader(fpState, ckt, inst);

View File

@ -20,7 +20,7 @@ $Id$
#define NIL(type) ((type *)0)
#define TSCALLOC(var, size, type)\
if (size && (!(var =(type *)calloc(1, (unsigned)(size)*sizeof(type))))) {\
if (size && (var = (type *)calloc(1, (unsigned)(size)*sizeof(type))) == NULL) {\
return(E_NOMEM);\
}

View File

@ -63,7 +63,7 @@ static int EVTinit_limits(CKTcircuit *ckt);
/* Adapted from SPICE 3C1 code in CKTsetup.c */
#define CKALLOC(var,size,type) \
if(size) { \
if(!(var = TMALLOC(type, size))) \
if((var = TMALLOC(type, size)) == NULL) \
return(E_NOMEM); \
}

View File

@ -72,16 +72,16 @@ static int EVTsetup_load_ptrs(CKTcircuit *ckt);
#define CKALLOC(var,size,type) \
if(size) { \
if(!(var = TMALLOC(type, size))) \
if((var = TMALLOC(type, size)) == NULL) \
return(E_NOMEM); \
}
#define CKREALLOC(var,size,type) \
if((size) == 1) { \
if(!(var = TMALLOC(type, size))) \
if((var = TMALLOC(type, size)) == NULL) \
return(E_NOMEM); \
} else if((size) > 1) { \
if(!(var = TREALLOC(type, (var), size))) \
if((var = TREALLOC(type, (var), size)) == NULL) \
return(E_NOMEM); \
}