diff --git a/ChangeLog b/ChangeLog index 877815674..cca342f1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/ciderlib/support/logfile.c b/src/ciderlib/support/logfile.c index c03e8f508..d716ab193 100644 --- a/src/ciderlib/support/logfile.c +++ b/src/ciderlib/support/logfile.c @@ -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); diff --git a/src/ciderlib/support/suprem.c b/src/ciderlib/support/suprem.c index 9fac7dde1..07acc0b1c 100644 --- a/src/ciderlib/support/suprem.c +++ b/src/ciderlib/support/suprem.c @@ -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); } diff --git a/src/ciderlib/support/suprmitf.c b/src/ciderlib/support/suprmitf.c index 4d4fab5fa..238d3fecf 100644 --- a/src/ciderlib/support/suprmitf.c +++ b/src/ciderlib/support/suprmitf.c @@ -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; } diff --git a/src/frontend/aspice.c b/src/frontend/aspice.c index a9ec4e2de..e2e3c618d 100644 --- a/src/frontend/aspice.c +++ b/src/frontend/aspice.c @@ -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; diff --git a/src/frontend/com_compose.c b/src/frontend/com_compose.c index 5e888f23f..0859de10f 100644 --- a/src/frontend/com_compose.c +++ b/src/frontend/com_compose.c @@ -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); diff --git a/src/frontend/com_ghelp.c b/src/frontend/com_ghelp.c index dc9a48de4..2506e65cb 100644 --- a/src/frontend/com_ghelp.c +++ b/src/frontend/com_ghelp.c @@ -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); diff --git a/src/frontend/com_measure2.c b/src/frontend/com_measure2.c index ee174638e..082375553 100644 --- a/src/frontend/com_measure2.c +++ b/src/frontend/com_measure2.c @@ -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; } diff --git a/src/frontend/control.c b/src/frontend/control.c index dfcffcf64..b9a4db6c7 100644 --- a/src/frontend/control.c +++ b/src/frontend/control.c @@ -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; } diff --git a/src/frontend/cpitf.c b/src/frontend/cpitf.c index 4cc023a1d..37bab9e74 100644 --- a/src/frontend/cpitf.c +++ b/src/frontend/cpitf.c @@ -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); } diff --git a/src/frontend/define.c b/src/frontend/define.c index ec2b6b37d..9340f632c 100644 --- a/src/frontend/define.c +++ b/src/frontend/define.c @@ -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 diff --git a/src/frontend/dotcards.c b/src/frontend/dotcards.c index fbd3a6ea9..8b7778ec1 100644 --- a/src/frontend/dotcards.c +++ b/src/frontend/dotcards.c @@ -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; diff --git a/src/frontend/fourier.c b/src/frontend/fourier.c index 7dc63ff92..89842f49a 100644 --- a/src/frontend/fourier.c +++ b/src/frontend/fourier.c @@ -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; } diff --git a/src/frontend/help/help.c b/src/frontend/help/help.c index 002ba7e80..6ee3a2c95 100644 --- a/src/frontend/help/help.c +++ b/src/frontend/help/help.c @@ -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); } diff --git a/src/frontend/help/provide.c b/src/frontend/help/provide.c index 7afcdf301..c06055c7e 100644 --- a/src/frontend/help/provide.c +++ b/src/frontend/help/provide.c @@ -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; diff --git a/src/frontend/help/readhelp.c b/src/frontend/help/readhelp.c index 26aed8c61..18befbb8e 100644 --- a/src/frontend/help/readhelp.c +++ b/src/frontend/help/readhelp.c @@ -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); } diff --git a/src/frontend/hpgl.c b/src/frontend/hpgl.c index 92a249c3d..c6c4b87e3 100644 --- a/src/frontend/hpgl.c +++ b/src/frontend/hpgl.c @@ -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); diff --git a/src/frontend/inp.c b/src/frontend/inp.c index a4928c0d2..70c2a9709 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -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; diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 1e0c8e104..265e1fe9c 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -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 */ diff --git a/src/frontend/nutinp.c b/src/frontend/nutinp.c index b962e9fb3..b5f9cc34b 100644 --- a/src/frontend/nutinp.c +++ b/src/frontend/nutinp.c @@ -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; diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index 86ce22500..6cb869763 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -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; diff --git a/src/frontend/parser/backq.c b/src/frontend/parser/backq.c index 1920b30b0..561e3fba2 100644 --- a/src/frontend/parser/backq.c +++ b/src/frontend/parser/backq.c @@ -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); } diff --git a/src/frontend/plotting/gnuplot.c b/src/frontend/plotting/gnuplot.c index 521e777f0..7ac9ef0ff 100644 --- a/src/frontend/plotting/gnuplot.c +++ b/src/frontend/plotting/gnuplot.c @@ -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; } diff --git a/src/frontend/plotting/graf.c b/src/frontend/plotting/graf.c index 6e29b3bbc..375dcc6cd 100644 --- a/src/frontend/plotting/graf.c +++ b/src/frontend/plotting/graf.c @@ -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); } diff --git a/src/frontend/plotting/graphdb.c b/src/frontend/plotting/graphdb.c index 3a655ffce..82d09e648 100644 --- a/src/frontend/plotting/graphdb.c +++ b/src/frontend/plotting/graphdb.c @@ -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); } diff --git a/src/frontend/plotting/plot5.c b/src/frontend/plotting/plot5.c index 5e150c997..9a0e91dcc 100644 --- a/src/frontend/plotting/plot5.c +++ b/src/frontend/plotting/plot5.c @@ -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); diff --git a/src/frontend/plotting/plotit.c b/src/frontend/plotting/plotit.c index 3016891eb..a4bc1af1e 100644 --- a/src/frontend/plotting/plotit.c +++ b/src/frontend/plotting/plotit.c @@ -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; diff --git a/src/frontend/plotting/xgraph.c b/src/frontend/plotting/xgraph.c index 5eb146cfa..3693c6404 100644 --- a/src/frontend/plotting/xgraph.c +++ b/src/frontend/plotting/xgraph.c @@ -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; } diff --git a/src/frontend/postcoms.c b/src/frontend/postcoms.c index 24ac8ef0e..a75f681bd 100644 --- a/src/frontend/postcoms.c +++ b/src/frontend/postcoms.c @@ -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); diff --git a/src/frontend/postsc.c b/src/frontend/postsc.c index 3daeec9d4..29a4833f3 100644 --- a/src/frontend/postsc.c +++ b/src/frontend/postsc.c @@ -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); diff --git a/src/frontend/rawfile.c b/src/frontend/rawfile.c index c9365977a..7e745d48a 100644 --- a/src/frontend/rawfile.c +++ b/src/frontend/rawfile.c @@ -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; } diff --git a/src/frontend/runcoms.c b/src/frontend/runcoms.c index 13e77b1d7..fdb44e1a6 100644 --- a/src/frontend/runcoms.c +++ b/src/frontend/runcoms.c @@ -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; diff --git a/src/frontend/runcoms2.c b/src/frontend/runcoms2.c index f2338fd55..5c1bb57d1 100644 --- a/src/frontend/runcoms2.c +++ b/src/frontend/runcoms2.c @@ -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; diff --git a/src/frontend/spec.c b/src/frontend/spec.c index 7a662b6d6..0bbac05c1 100644 --- a/src/frontend/spec.c +++ b/src/frontend/spec.c @@ -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; } diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index de7188382..199619a34 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -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; diff --git a/src/frontend/typesdef.c b/src/frontend/typesdef.c index afa2ed93d..7d014f890 100644 --- a/src/frontend/typesdef.c +++ b/src/frontend/typesdef.c @@ -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) { diff --git a/src/frontend/variable.c b/src/frontend/variable.c index 84ea090c9..31516a333 100644 --- a/src/frontend/variable.c +++ b/src/frontend/variable.c @@ -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); } diff --git a/src/frontend/vectors.c b/src/frontend/vectors.c index ef185e603..17d7a13c1 100644 --- a/src/frontend/vectors.c +++ b/src/frontend/vectors.c @@ -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); diff --git a/src/include/memory.h b/src/include/memory.h index 817522323..5aa3be6ca 100644 --- a/src/include/memory.h +++ b/src/include/memory.h @@ -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 ); \ } diff --git a/src/main.c b/src/main.c index 2b8b824e2..744c2a772 100644 --- a/src/main.c +++ b/src/main.c @@ -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))) { diff --git a/src/spicelib/analysis/cktsetup.c b/src/spicelib/analysis/cktsetup.c index e7a27c370..8d42ff710 100644 --- a/src/spicelib/analysis/cktsetup.c +++ b/src/spicelib/analysis/cktsetup.c @@ -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);\ } diff --git a/src/spicelib/devices/nbjt/nbjtdump.c b/src/spicelib/devices/nbjt/nbjtdump.c index d631b7151..7e256691f 100644 --- a/src/spicelib/devices/nbjt/nbjtdump.c +++ b/src/spicelib/devices/nbjt/nbjtdump.c @@ -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); diff --git a/src/spicelib/devices/nbjt/nbjtset.c b/src/spicelib/devices/nbjt/nbjtset.c index 9f8d171f6..f106b4c97 100644 --- a/src/spicelib/devices/nbjt/nbjtset.c +++ b/src/spicelib/devices/nbjt/nbjtset.c @@ -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);\ } diff --git a/src/spicelib/devices/nbjt2/nbt2dump.c b/src/spicelib/devices/nbjt2/nbt2dump.c index 7e754ea3e..9915bb721 100644 --- a/src/spicelib/devices/nbjt2/nbt2dump.c +++ b/src/spicelib/devices/nbjt2/nbt2dump.c @@ -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); diff --git a/src/spicelib/devices/nbjt2/nbt2set.c b/src/spicelib/devices/nbjt2/nbt2set.c index cbb56d174..867a20a91 100644 --- a/src/spicelib/devices/nbjt2/nbt2set.c +++ b/src/spicelib/devices/nbjt2/nbt2set.c @@ -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);\ } diff --git a/src/spicelib/devices/ndev/ndevset.c b/src/spicelib/devices/ndev/ndevset.c index b5fc17722..27b3494a0 100644 --- a/src/spicelib/devices/ndev/ndevset.c +++ b/src/spicelib/devices/ndev/ndevset.c @@ -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);\ } diff --git a/src/spicelib/devices/numd/numddump.c b/src/spicelib/devices/numd/numddump.c index 795cf257a..e1ce4f321 100644 --- a/src/spicelib/devices/numd/numddump.c +++ b/src/spicelib/devices/numd/numddump.c @@ -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); diff --git a/src/spicelib/devices/numd/numdset.c b/src/spicelib/devices/numd/numdset.c index e946db56f..2fb740e7e 100644 --- a/src/spicelib/devices/numd/numdset.c +++ b/src/spicelib/devices/numd/numdset.c @@ -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);\ } diff --git a/src/spicelib/devices/numd2/nud2dump.c b/src/spicelib/devices/numd2/nud2dump.c index 21d6e07dd..de999dae7 100644 --- a/src/spicelib/devices/numd2/nud2dump.c +++ b/src/spicelib/devices/numd2/nud2dump.c @@ -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); diff --git a/src/spicelib/devices/numd2/nud2set.c b/src/spicelib/devices/numd2/nud2set.c index cf7f2990f..6805a043c 100644 --- a/src/spicelib/devices/numd2/nud2set.c +++ b/src/spicelib/devices/numd2/nud2set.c @@ -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);\ } diff --git a/src/spicelib/devices/numos/nummdump.c b/src/spicelib/devices/numos/nummdump.c index 300181e47..63fe99504 100644 --- a/src/spicelib/devices/numos/nummdump.c +++ b/src/spicelib/devices/numos/nummdump.c @@ -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); diff --git a/src/spicelib/devices/numos/nummset.c b/src/spicelib/devices/numos/nummset.c index 299cd7765..ceec06bec 100644 --- a/src/spicelib/devices/numos/nummset.c +++ b/src/spicelib/devices/numos/nummset.c @@ -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);\ } diff --git a/src/xspice/evt/evtinit.c b/src/xspice/evt/evtinit.c index b8e8d5c01..3c6dba522 100755 --- a/src/xspice/evt/evtinit.c +++ b/src/xspice/evt/evtinit.c @@ -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); \ } diff --git a/src/xspice/evt/evtsetup.c b/src/xspice/evt/evtsetup.c index 683998e10..1db813c7b 100755 --- a/src/xspice/evt/evtsetup.c +++ b/src/xspice/evt/evtsetup.c @@ -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); \ }