Browse Source

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

pre-master-46
rlar 16 years ago
parent
commit
e6c30efe46
  1. 4
      ChangeLog
  2. 2
      src/frontend/com_compose.c
  3. 2
      src/frontend/com_history.c
  4. 4
      src/frontend/com_let.c
  5. 2
      src/frontend/com_measure2.c
  6. 6
      src/frontend/cpitf.c
  7. 2
      src/frontend/dotcards.c
  8. 6
      src/frontend/help/readhelp.c
  9. 50
      src/frontend/inpcom.c
  10. 4
      src/frontend/measure.c
  11. 4
      src/frontend/newcoms.c
  12. 2
      src/frontend/numparam/mystring.c
  13. 2
      src/frontend/numparam/xpressn.c
  14. 10
      src/frontend/options.c
  15. 8
      src/frontend/outitf.c
  16. 4
      src/frontend/parser/complete.c
  17. 2
      src/frontend/plotting/graf.c
  18. 4
      src/frontend/plotting/grid.c
  19. 2
      src/frontend/plotting/x11.c
  20. 10
      src/frontend/rawfile.c
  21. 6
      src/frontend/subckt.c
  22. 6
      src/frontend/terminal.c
  23. 8
      src/frontend/variable.c
  24. 2
      src/frontend/wdisp/windisp.c
  25. 2
      src/maths/sparse/spsmp.c
  26. 20
      src/misc/hash.c
  27. 2
      src/misc/ivars.c
  28. 6
      src/misc/string.c
  29. 2
      src/xspice/evt/evtdump.c

4
ChangeLog

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

2
src/frontend/com_compose.c

@ -212,7 +212,7 @@ com_compose(wordlist *wl)
} else { } else {
/* Parse the line... */ /* Parse the line... */
while (wl) { while (wl) {
if ((s =strchr(wl->wl_word, '=')) && s[1]) {
if ((s = strchr(wl->wl_word, '=')) != NULL && s[1]) {
/* This is var=val. */ /* This is var=val. */
*s = '\0'; *s = '\0';
var = wl->wl_word; var = wl->wl_word;

2
src/frontend/com_history.c

@ -124,7 +124,7 @@ dohsubst(char *string)
case '?': case '?':
(void) strcpy(buf, string + 1); (void) strcpy(buf, string + 1);
if ((s =strchr(buf, '?')))
if ((s = strchr(buf, '?')) != NULL)
*s = '\0'; *s = '\0';
wl = hpattern(buf); wl = hpattern(buf);
if (!wl) if (!wl)

4
src/frontend/com_let.c

@ -37,14 +37,14 @@ com_let(wordlist *wl)
/* extract indices */ /* extract indices */
numdims = 0; numdims = 0;
if ((rhs =strchr(p, '='))) {
if ((rhs = strchr(p, '=')) != NULL) {
*rhs++ = 0; *rhs++ = 0;
} else { } else {
fprintf(cp_err, "Error: bad let syntax\n"); fprintf(cp_err, "Error: bad let syntax\n");
tfree(p); tfree(p);
return; return;
} }
if ((s =strchr(p, '['))) {
if ((s = strchr(p, '[')) != NULL) {
need_open = 0; need_open = 0;
*s++ = 0; *s++ = 0;
while (!need_open || *s == '[') { while (!need_open || *s == '[') {

2
src/frontend/com_measure2.c

@ -65,7 +65,7 @@ measure_get_precision(void)
char *env_ptr; char *env_ptr;
int precision = 5; int precision = 5;
if ( ( env_ptr = getenv("NGSPICE_MEAS_PRECISION") ) ) {
if (( env_ptr = getenv("NGSPICE_MEAS_PRECISION")) != NULL) {
precision = atoi(env_ptr); precision = atoi(env_ptr);
} }

6
src/frontend/cpitf.c

@ -247,7 +247,7 @@ ft_cpinit(void)
/* add "spinit" to buf after actual position */ /* add "spinit" to buf after actual position */
(void) strcat(r, "spinit"); (void) strcat(r, "spinit");
#endif #endif
if ((fp = fopen(buf, "r"))) {
if ((fp = fopen(buf, "r")) != NULL) {
cp_interactive = FALSE; cp_interactive = FALSE;
inp_spsource(fp, TRUE, buf); inp_spsource(fp, TRUE, buf);
cp_interactive = TRUE; cp_interactive = TRUE;
@ -255,7 +255,7 @@ ft_cpinit(void)
break; break;
#if defined (HAS_WINDOWS) || defined (__MINGW32__) || defined (_MSC_VER) #if defined (HAS_WINDOWS) || defined (__MINGW32__) || defined (_MSC_VER)
/* search in local directory where ngspice.exe resides */ /* search in local directory where ngspice.exe resides */
} else if ((fp = fopen("./spinit", "r"))) {
} else if ((fp = fopen("./spinit", "r")) != NULL) {
cp_interactive = FALSE; cp_interactive = FALSE;
inp_spsource(fp, TRUE, buf); inp_spsource(fp, TRUE, buf);
cp_interactive = TRUE; cp_interactive = TRUE;
@ -348,7 +348,7 @@ cp_oddcomm(char *s, wordlist *wl)
char buf[BSIZE_SP]; char buf[BSIZE_SP];
wordlist ww; wordlist ww;
if ((fp = inp_pathopen(s, "r"))) {
if ((fp = inp_pathopen(s, "r")) != NULL) {
(void) fclose(fp); (void) fclose(fp);
(void) sprintf(buf, "argc = %d argv = ( ", wl_length(wl)); (void) sprintf(buf, "argc = %d argv = ( ", wl_length(wl));
while (wl) { while (wl) {

2
src/frontend/dotcards.c

@ -540,7 +540,7 @@ gettoks(char *s)
prevp = &list; prevp = &list;
if (strstr( s, "(" )) s = stripWhiteSpacesInsideParens(s); if (strstr( s, "(" )) s = stripWhiteSpacesInsideParens(s);
while ((t = gettok(&s))) {
while ((t = gettok(&s)) != NULL) {
if (*t == '(') if (*t == '(')
continue; continue;
l =strrchr(t, '('/*)*/); l =strrchr(t, '('/*)*/);

6
src/frontend/help/readhelp.c

@ -129,7 +129,7 @@ endtext:
s = &buf[10]; s = &buf[10];
/* process tokens within line, updating pointer */ /* process tokens within line, updating pointer */
while (*s) { while (*s) {
if ((topiclink = getsubtoplink(&s))) {
if ((topiclink = getsubtoplink(&s)) != NULL) {
if (tend) if (tend)
tend->next = topiclink; tend->next = topiclink;
else else
@ -146,7 +146,7 @@ endtext:
s = &buf[9]; s = &buf[9];
/* process tokens within line, updating pointer */ /* process tokens within line, updating pointer */
while (*s) { while (*s) {
if ((topiclink = getsubtoplink(&s))) {
if ((topiclink = getsubtoplink(&s)) != NULL) {
if (tend) if (tend)
tend->next = topiclink; tend->next = topiclink;
else else
@ -186,7 +186,7 @@ static toplink *getsubtoplink(char **ss)
s = *ss; s = *ss;
tl = alloc(toplink); tl = alloc(toplink);
if ((tmp =strchr(s, ':'))) {
if ((tmp =strchr(s, ':')) != NULL) {
tl->place = alloc(fplace); tl->place = alloc(fplace);
tl->place->filename = strncpy( tl->place->filename = strncpy(
TMALLOC(char, tmp - s + 1), TMALLOC(char, tmp - s + 1),

50
src/frontend/inpcom.c

@ -189,7 +189,7 @@ inp_pathopen(char *name, char *mode)
/* add file name */ /* add file name */
strcat(buf2, name); strcat(buf2, name);
/* try to open file */ /* try to open file */
if ((fp = fopen(buf2, mode)))
if ((fp = fopen(buf2, mode)) != NULL)
return (fp); return (fp);
} }
#endif #endif
@ -219,7 +219,7 @@ inp_pathopen(char *name, char *mode)
controlled_exit(EXIT_FAILURE); controlled_exit(EXIT_FAILURE);
} }
} }
if ((fp = fopen(buf, mode)))
if ((fp = fopen(buf, mode)) != NULL)
return (fp); return (fp);
v = v->va_next; v = v->va_next;
} }
@ -238,7 +238,7 @@ inp_fix_gnd_name( struct line *deck ) {
// if there is a comment or no gnd, go to next line // if there is a comment or no gnd, go to next line
if (( *gnd == '*' ) || (strstr( gnd, "gnd" ) == NULL)) { c = c->li_next; continue; } if (( *gnd == '*' ) || (strstr( gnd, "gnd" ) == NULL)) { c = c->li_next; continue; }
// replace "§gnd§" by "§ 0 §", § being a ' ' ',' '(' ')'. // replace "§gnd§" by "§ 0 §", § being a ' ' ',' '(' ')'.
while ( (gnd = strstr( gnd, "gnd" ) ) ) {
while ((gnd = strstr( gnd, "gnd" )) != NULL) {
if (( isspace(*(gnd-1)) || *(gnd-1) == '(' || *(gnd-1) == ',' ) && if (( isspace(*(gnd-1)) || *(gnd-1) == '(' || *(gnd-1) == ',' ) &&
( isspace(*(gnd+3)) || *(gnd+3) == ')' || *(gnd+3) == ',' )) ( isspace(*(gnd+3)) || *(gnd+3) == ')' || *(gnd+3) == ',' ))
{ {
@ -278,10 +278,10 @@ inp_chk_for_multi_in_vcvs( struct line *deck, int *line_number ) {
for ( c = deck; c != NULL; c = c->li_next ) { for ( c = deck; c != NULL; c = c->li_next ) {
str_ptr1 = line = c->li_line; str_ptr1 = line = c->li_line;
if ( *line == 'e' ) { if ( *line == 'e' ) {
if ( (bool_ptr = strstr( line, "nand(" )) ||
(bool_ptr = strstr( line, "and(" )) ||
(bool_ptr = strstr( line, "nor(" )) ||
(bool_ptr = strstr( line, "or(" )) ) {
if ( (bool_ptr = strstr( line, "nand(" )) != NULL ||
(bool_ptr = strstr( line, "and(" )) != NULL ||
(bool_ptr = strstr( line, "nor(" )) != NULL ||
(bool_ptr = strstr( line, "or(" )) != NULL ) {
while ( !isspace(*str_ptr1) ) str_ptr1++; while ( !isspace(*str_ptr1) ) str_ptr1++;
keep = *str_ptr1; keep = *str_ptr1;
*str_ptr1 = '\0'; *str_ptr1 = '\0';
@ -539,7 +539,7 @@ get_instance_subckt( char *line )
char keep = ' '; char keep = ' ';
// see if instance has parameters // see if instance has parameters
if ( ( equal_ptr = strstr( line, "=" ) ) ) {
if ((equal_ptr = strstr(line, "=")) != NULL) {
end_ptr = equal_ptr - 1; end_ptr = equal_ptr - 1;
while ( isspace(*end_ptr) ) end_ptr--; while ( isspace(*end_ptr) ) end_ptr--;
while ( !isspace(*end_ptr) ) end_ptr--; while ( !isspace(*end_ptr) ) end_ptr--;
@ -718,7 +718,7 @@ model_bin_match( char* token, char* model_name )
bool flag = FALSE; bool flag = FALSE;
if ( strncmp( model_name, token, strlen(token) ) == 0 ) { if ( strncmp( model_name, token, strlen(token) ) == 0 ) {
if ( (dot_char = strstr( model_name, "." )) ) {
if ((dot_char = strstr( model_name, "." )) != NULL) {
flag = TRUE; flag = TRUE;
dot_char++; dot_char++;
while( *dot_char != '\0' ) { while( *dot_char != '\0' ) {
@ -951,7 +951,7 @@ inp_fix_ternary_operator_str( char *line )
str_ptr2 = colon - 1; str_ptr2 = colon - 1;
while ( isspace(*str_ptr2) ) str_ptr2--; while ( isspace(*str_ptr2) ) str_ptr2--;
} }
else if ( ( colon = strstr( str_ptr, ":" ) ) ) {
else if ((colon = strstr( str_ptr, ":" )) != NULL) {
str_ptr2 = colon - 1; str_ptr2 = colon - 1;
while ( isspace(*str_ptr2) ) str_ptr2--; while ( isspace(*str_ptr2) ) str_ptr2--;
} }
@ -992,7 +992,7 @@ inp_fix_ternary_operator_str( char *line )
*str_ptr2 = keep; *str_ptr2 = keep;
} }
else { else {
if ( ( str_ptr2 = strstr( str_ptr, "}" ) ) ) {
if ((str_ptr2 = strstr(str_ptr, "}")) != NULL) {
*str_ptr2 = '\0'; *str_ptr2 = '\0';
else_str = inp_fix_ternary_operator_str(strdup(str_ptr)); else_str = inp_fix_ternary_operator_str(strdup(str_ptr));
*str_ptr2 = '}'; *str_ptr2 = '}';
@ -1147,7 +1147,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c
/* gtri - end - 12/12/90 */ /* gtri - end - 12/12/90 */
#else #else
while ((buffer = readline(fp))) {
while ((buffer = readline(fp)) != NULL) {
#endif #endif
#ifdef TRACE #ifdef TRACE
@ -1402,7 +1402,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c
end->li_linenum = line_number++; end->li_linenum = line_number++;
end->li_linenum_orig = line_number_orig++; end->li_linenum_orig = line_number_orig++;
tfree(buffer); tfree(buffer);
} /* end while ((buffer = readline(fp))) */
} /* end while ((buffer = readline(fp)) != NULL) */
if (!end) { /* No stuff here */ if (!end) { /* No stuff here */
*data = NULL; *data = NULL;
@ -1849,7 +1849,7 @@ inp_fix_subckt( char *s )
head = alloc(struct line); head = alloc(struct line);
/* create list of parameters that need to get sorted */ /* create list of parameters that need to get sorted */
while ( *beg && (ptr1 = strstr( beg, "=" ) ) ) {
while ( *beg && (ptr1 = strstr( beg, "=" )) != NULL ) {
ptr2 = ptr1+1; ptr2 = ptr1+1;
ptr1--; ptr1--;
while ( isspace(*ptr1) ) ptr1--; while ( isspace(*ptr1) ) ptr1--;
@ -2131,7 +2131,7 @@ inp_get_params( char *line, char *param_names[], char *param_values[] )
char keep; char keep;
bool is_expression = FALSE; bool is_expression = FALSE;
while ( ( equal_ptr = strstr( line, "=" ) ) ) {
while ( (equal_ptr = strstr( line, "=" )) != NULL ) {
// check for equality '==' // check for equality '=='
if ( *(equal_ptr+1) == '=' ) { line = equal_ptr+2; continue; } if ( *(equal_ptr+1) == '=' ) { line = equal_ptr+2; continue; }
@ -2534,7 +2534,7 @@ inp_do_macro_param_replace( int fcn_number, char *params[] )
search_ptr = curr_ptr = curr_str; search_ptr = curr_ptr = curr_str;
curr_str = NULL; curr_str = NULL;
} }
while ( ( param_ptr = strstr( search_ptr, func_params[fcn_number][i] ) ) ) {
while ((param_ptr = strstr( search_ptr, func_params[fcn_number][i] ) ) != NULL ) {
/* make sure actually have the parameter name */ /* make sure actually have the parameter name */
if (param_ptr == search_ptr) /* no valid 'before' */ if (param_ptr == search_ptr) /* no valid 'before' */
@ -2600,7 +2600,7 @@ inp_expand_macro_in_str( char *str )
char *orig_ptr = str, *search_ptr = str, *orig_str = strdup(str); char *orig_ptr = str, *search_ptr = str, *orig_str = strdup(str);
char keep; char keep;
while ( ( open_paren_ptr = strstr( search_ptr, "(" ) ) ) {
while ( (open_paren_ptr = strstr( search_ptr, "(" )) != NULL ) {
fcn_name = open_paren_ptr; fcn_name = open_paren_ptr;
if ( open_paren_ptr != search_ptr) { if ( open_paren_ptr != search_ptr) {
while ( --fcn_name != search_ptr && (isalnum(*fcn_name) || *fcn_name == '_') ) while ( --fcn_name != search_ptr && (isalnum(*fcn_name) || *fcn_name == '_') )
@ -2793,7 +2793,7 @@ inp_fix_param_values( struct line *deck )
/* exclude CIDER devices with ic.file parameter */ /* exclude CIDER devices with ic.file parameter */
if ( strstr(line, "ic.file")) { c = c->li_next; continue; } if ( strstr(line, "ic.file")) { c = c->li_next; continue; }
while ( ( equal_ptr = strstr( line, "=" ) ) ) {
while ((equal_ptr = strstr( line, "=" )) != NULL ) {
// special case: .MEASURE {DC|AC|TRAN} result FIND out_variable WHEN out_variable2=out_variable3 // special case: .MEASURE {DC|AC|TRAN} result FIND out_variable WHEN out_variable2=out_variable3
// no braces around out_variable3. out_variable3 may be v(...) or i(...) // no braces around out_variable3. out_variable3 may be v(...) or i(...)
@ -2974,7 +2974,7 @@ get_param_name( char *line )
char *name = NULL, *equal_ptr, *beg; char *name = NULL, *equal_ptr, *beg;
char keep; char keep;
if ( ( equal_ptr = strstr( line, "=" ) ) )
if (( equal_ptr = strstr( line, "=" ) ) != NULL )
{ {
equal_ptr--; equal_ptr--;
while ( isspace(*equal_ptr) ) equal_ptr--; while ( isspace(*equal_ptr) ) equal_ptr--;
@ -3001,7 +3001,7 @@ get_param_str( char *line )
{ {
char *equal_ptr; char *equal_ptr;
if ( ( equal_ptr = strstr( line, "=" ) ) ) {
if (( equal_ptr = strstr( line, "=" ) ) != NULL ) {
equal_ptr++; equal_ptr++;
while ( isspace(*equal_ptr) ) equal_ptr++; while ( isspace(*equal_ptr) ) equal_ptr++;
return equal_ptr; return equal_ptr;
@ -3089,7 +3089,7 @@ get_number_terminals( char *c )
name[i] = gettok_instance(&c); name[i] = gettok_instance(&c);
if (strstr(name[i], "off") || strstr(name[i], "=")) j++; if (strstr(name[i], "off") || strstr(name[i], "=")) j++;
/* If we have IC=VBE, VCE instead of IC=VBE,VCE we need to inc j */ /* If we have IC=VBE, VCE instead of IC=VBE,VCE we need to inc j */
if ((comma = strstr(name[i], ",")) && ( *(++comma) == '\0')) j++;
if ((comma = strstr(name[i], ",")) != NULL && ( *(++comma) == '\0')) j++;
/* If we have IC=VBE , VCE ("," is a token) we need to inc j */ /* If we have IC=VBE , VCE ("," is a token) we need to inc j */
if (eq(name[i], ",")) j++; if (eq(name[i], ",")) j++;
i++; i++;
@ -3218,7 +3218,7 @@ inp_sort_params( struct line *start_card, struct line *end_card, struct line *ca
param_str = param_strs[j]; param_str = param_strs[j];
while ( ( param_ptr = strstr( param_str, param_name ) ) )
while ((param_ptr = strstr( param_str, param_name ) ) != NULL )
{ {
ioff = (strstr(param_ptr, "}") != NULL ? 1 : 0); /* want prevent wrong memory access below */ ioff = (strstr(param_ptr, "}") != NULL ? 1 : 0); /* want prevent wrong memory access below */
/* looking for curly braces or other string limiter */ /* looking for curly braces or other string limiter */
@ -3274,7 +3274,7 @@ inp_sort_params( struct line *start_card, struct line *end_card, struct line *ca
while ( isspace(*str_ptr) && *str_ptr != '\0' ) str_ptr++; while ( isspace(*str_ptr) && *str_ptr != '\0' ) str_ptr++;
} }
while ( ( str_ptr = strstr( str_ptr, param_names[i] ) ) )
while ((str_ptr = strstr( str_ptr, param_names[i] ) ) != NULL )
{ {
/* make sure actually have the parameter name */ /* make sure actually have the parameter name */
char before = *(str_ptr-1); char before = *(str_ptr-1);
@ -3475,7 +3475,7 @@ inp_split_multi_param_lines( struct line *deck, int line_num )
if ( ciprefix( ".param", curr_line ) ) if ( ciprefix( ".param", curr_line ) )
{ {
counter = 0; counter = 0;
while ( ( equal_ptr = strstr( curr_line, "=" ) ) ) {
while (( equal_ptr = strstr( curr_line, "=" ) ) != NULL ) {
// check for equality '==' // check for equality '=='
if ( *(equal_ptr+1) == '=' ) { curr_line = equal_ptr+2; continue; } if ( *(equal_ptr+1) == '=' ) { curr_line = equal_ptr+2; continue; }
// check for '!=', '<=', '>=' // check for '!=', '<=', '>='
@ -3487,7 +3487,7 @@ inp_split_multi_param_lines( struct line *deck, int line_num )
// need to split multi param line // need to split multi param line
curr_line = card->li_line; curr_line = card->li_line;
counter = 0; counter = 0;
while ( curr_line < card->li_line+strlen(card->li_line) && ( equal_ptr = strstr( curr_line, "=" ) ) )
while ( curr_line < card->li_line+strlen(card->li_line) && ( equal_ptr = strstr( curr_line, "=" ) ) != NULL )
{ {
// check for equality '==' // check for equality '=='
if ( *(equal_ptr+1) == '=' ) { curr_line = equal_ptr+2; continue; } if ( *(equal_ptr+1) == '=' ) { curr_line = equal_ptr+2; continue; }

4
src/frontend/measure.c

@ -83,7 +83,7 @@ com_meas(wordlist *wl) {
} }
} }
/* may be inside the same wl_word */ /* may be inside the same wl_word */
else if ( (equal_ptr = strstr( token, "=" )) ) {
else if ( (equal_ptr = strstr( token, "=" )) != NULL ) {
vec_found = equal_ptr + 1; vec_found = equal_ptr + 1;
if (!cieq(vec_found, "LAST")) { if (!cieq(vec_found, "LAST")) {
INPevaluate( &vec_found, &err, 1 ); INPevaluate( &vec_found, &err, 1 );
@ -162,7 +162,7 @@ get_double_value(
*value = INPevaluate( &junk, &err, 1 ); *value = INPevaluate( &junk, &err, 1 );
} else { } else {
if ( (equal_ptr = strstr( token, "=" )) ) {
if ( (equal_ptr = strstr( token, "=" )) != NULL ) {
equal_ptr += 1; equal_ptr += 1;
*value = INPevaluate( &equal_ptr, &err, 1 ); *value = INPevaluate( &equal_ptr, &err, 1 );
} else { } else {

4
src/frontend/newcoms.c

@ -45,7 +45,7 @@ com_reshape(wordlist *wl)
p = NULL; p = NULL;
for (w = wl; w; w = w->wl_next) { for (w = wl; w; w = w->wl_next) {
if ((p =strchr(w->wl_word, '[')))
if ((p = strchr(w->wl_word, '[')) != NULL)
break; break;
} }
@ -210,5 +210,5 @@ com_reshape(wordlist *wl)
if (vname) if (vname)
tfree(vname); tfree(vname);
} }
} while ((wl = wlast));
} while ((wl = wlast) != NULL);
} }

2
src/frontend/numparam/mystring.c

@ -865,7 +865,7 @@ spos_(char *sub, char *s)
{ {
char *ptr; char *ptr;
if ((ptr = strstr (s, sub)))
if ((ptr = strstr (s, sub)) != NULL)
return (int) (strlen (s) - strlen (ptr)); return (int) (strlen (s) - strlen (ptr));
else else
return -1 ; return -1 ;

2
src/frontend/numparam/xpressn.c

@ -2263,7 +2263,7 @@ nupa_subcktcall (tdico * dico, char *s, char *x, bool err)
token = strtok(buf, " "); /* a bit more exact - but not sufficient everytime */ token = strtok(buf, " "); /* a bit more exact - but not sufficient everytime */
j = j + (int) strlen(token) + 1; j = j + (int) strlen(token) + 1;
if (strcmp(token, spice_dstring_value(&subname))) { if (strcmp(token, spice_dstring_value(&subname))) {
while ((token = strtok(NULL, " "))) {
while ((token = strtok(NULL, " ")) != NULL) {
if (!strcmp(token, spice_dstring_value(&subname))) { if (!strcmp(token, spice_dstring_value(&subname))) {
found = 1; found = 1;
break; break;

10
src/frontend/options.c

@ -155,23 +155,23 @@ cp_usrvars(struct variable **v1, struct variable **v2)
v = plot_cur->pl_env; v = plot_cur->pl_env;
else else
v = NULL; v = NULL;
if ((tv = cp_enqvar("plots"))) {
if ((tv = cp_enqvar("plots")) != NULL) {
tv->va_next = v; tv->va_next = v;
v = tv; v = tv;
} }
if ((tv = cp_enqvar("curplot"))) {
if ((tv = cp_enqvar("curplot")) != NULL) {
tv->va_next = v; tv->va_next = v;
v = tv; v = tv;
} }
if ((tv = cp_enqvar("curplottitle"))) {
if ((tv = cp_enqvar("curplottitle")) != NULL) {
tv->va_next = v; tv->va_next = v;
v = tv; v = tv;
} }
if ((tv = cp_enqvar("curplotname"))) {
if ((tv = cp_enqvar("curplotname")) != NULL) {
tv->va_next = v; tv->va_next = v;
v = tv; v = tv;
} }
if ((tv = cp_enqvar("curplotdate"))) {
if ((tv = cp_enqvar("curplotdate")) != NULL) {
tv->va_next = v; tv->va_next = v;
v = tv; v = tv;
} }

8
src/frontend/outitf.c

@ -815,7 +815,7 @@ fileInit_pass2(runDesc *run)
if ( type == SV_CURRENT ) { if ( type == SV_CURRENT ) {
branch = NULL; branch = NULL;
if ( (branch = strstr( name, "#branch" )) ) {
if ( (branch = strstr( name, "#branch" )) != NULL ) {
*branch = '\0'; *branch = '\0';
} }
fprintf(run->fp, "\t%d\ti(%s)\t%s", i, name, ft_typenames(type)); fprintf(run->fp, "\t%d\ti(%s)\t%s", i, name, ft_typenames(type));
@ -1089,14 +1089,14 @@ name_eq(char *n1, char *n2)
{ {
char buf1[BSIZE_SP], buf2[BSIZE_SP], *s; char buf1[BSIZE_SP], buf2[BSIZE_SP], *s;
if ((s =strchr(n1, '('))) {
if ((s =strchr(n1, '(')) != NULL) {
strcpy(buf1, s); strcpy(buf1, s);
if (!(s =strchr(buf1, ')'))) if (!(s =strchr(buf1, ')')))
return FALSE; return FALSE;
*s = '\0'; *s = '\0';
n1 = buf1; n1 = buf1;
} }
if ((s =strchr(n2, '('))) {
if ((s =strchr(n2, '(')) != NULL) {
strcpy(buf2, s); strcpy(buf2, s);
if (!(s =strchr(buf2, ')'))) if (!(s =strchr(buf2, ')')))
return FALSE; return FALSE;
@ -1119,7 +1119,7 @@ getSpecial(dataDesc *desc, runDesc *run, IFvalue *val)
&selector) == OK) { &selector) == OK) {
desc->type &= (IF_REAL | IF_COMPLEX); /* mask out other bits */ desc->type &= (IF_REAL | IF_COMPLEX); /* mask out other bits */
return TRUE; return TRUE;
} else if ((vv = if_getstat(run->circuit, &desc->name[1]))) {
} else if ((vv = if_getstat(run->circuit, &desc->name[1])) != NULL) {
/* skip @ sign */ /* skip @ sign */
desc->type = IF_REAL; desc->type = IF_REAL;
if (vv->va_type == CP_REAL) if (vv->va_type == CP_REAL)

4
src/frontend/parser/complete.c

@ -215,7 +215,7 @@ ccfilec(char *buf)
lcomp = buf; lcomp = buf;
if (*buf == cp_til) { /* User name completion... */ if (*buf == cp_til) { /* User name completion... */
buf++; buf++;
while ((pw = getpwent())) {
while ((pw = getpwent()) != NULL) {
if (prefix(buf, pw->pw_name)) { if (prefix(buf, pw->pw_name)) {
if (wl == NULL) { if (wl == NULL) {
wl = alloc(struct wordlist); wl = alloc(struct wordlist);
@ -246,7 +246,7 @@ ccfilec(char *buf)
} }
if (!(wdir = opendir(dir))) if (!(wdir = opendir(dir)))
return (NULL); return (NULL);
while ((de = readdir(wdir)))
while ((de = readdir(wdir)) != NULL)
if ((prefix(lcomp, de->d_name)) && (*lcomp || if ((prefix(lcomp, de->d_name)) && (*lcomp ||
(*de->d_name != '.'))) { (*de->d_name != '.'))) {
if (wl == NULL) { if (wl == NULL) {

2
src/frontend/plotting/graf.c

@ -279,7 +279,7 @@ gr_point(struct dvec *dv,
want to connect with oldx and oldy. */ want to connect with oldx and oldy. */
if (np) if (np)
DevDrawLine(fromx, fromy, tox, toy); DevDrawLine(fromx, fromy, tox, toy);
if ((tics = (double *) currentgraph->ticdata)) {
if ((tics = (double *) currentgraph->ticdata) != NULL) {
for (; *tics < HUGE; tics++) { for (; *tics < HUGE; tics++) {
if (*tics == (double) np) { if (*tics == (double) np) {
DevDrawText("x", (int) (tox - currentgraph->fontwidth / 2), DevDrawText("x", (int) (tox - currentgraph->fontwidth / 2),

4
src/frontend/plotting/grid.c

@ -350,7 +350,7 @@ lingrid(GRAPH *graph, double lo, double hi, double delta, int type, Axis axis)
(void) sprintf(buf, "x10^%d ", mag); (void) sprintf(buf, "x10^%d ", mag);
} }
if ((s = ft_typabbrev(type))) {
if ((s = ft_typabbrev(type)) != NULL) {
(void) strcat(buf, s); (void) strcat(buf, s);
} else { } else {
(void) strcat(buf, "Units"); (void) strcat(buf, "Units");
@ -612,7 +612,7 @@ loggrid(GRAPH *graph, double lo, double hi, int type, Axis axis)
dd[0] = pow(10.0, (double) lmt); dd[0] = pow(10.0, (double) lmt);
dd[1] = pow(10.0, (double) hmt); dd[1] = pow(10.0, (double) hmt);
if ((s = ft_typabbrev(type))) {
if ((s = ft_typabbrev(type)) != NULL) {
(void) strcpy(buf, s); (void) strcpy(buf, s);
} else { } else {
(void) strcpy(buf, "Units"); (void) strcpy(buf, "Units");

2
src/frontend/plotting/x11.c

@ -812,7 +812,7 @@ zoomin(GRAPH *graph)
} }
strncpy(buf2, graph->plotname, sizeof(buf2)); strncpy(buf2, graph->plotname, sizeof(buf2));
if ((t =strchr(buf2, ':')))
if ((t = strchr(buf2, ':')) != NULL)
*t = 0; *t = 0;
if (!eq(plot_cur->pl_typename, buf2)) { if (!eq(plot_cur->pl_typename, buf2)) {

10
src/frontend/rawfile.c

@ -157,7 +157,7 @@ raw_write(char *name, struct plot *pl, bool app, bool binary)
for (i = 0, v = pl->pl_dvecs; v; v = v->v_next) { for (i = 0, v = pl->pl_dvecs; v; v = v->v_next) {
if ( strcmp( ft_typenames(v->v_type), "current" ) == 0 ) { if ( strcmp( ft_typenames(v->v_type), "current" ) == 0 ) {
branch = NULL; branch = NULL;
if ( (branch = strstr( v->v_name, "#branch" )) ) {
if ((branch = strstr( v->v_name, "#branch" )) != NULL) {
*branch = '\0'; *branch = '\0';
} }
fprintf(fp, "\t%d\ti(%s)\t%s", i++, v->v_name, ft_typenames(v->v_type)); fprintf(fp, "\t%d\ti(%s)\t%s", i++, v->v_name, ft_typenames(v->v_type));
@ -372,7 +372,7 @@ raw_read(char *name)
} else if (ciprefix("flags:", buf)) { } else if (ciprefix("flags:", buf)) {
s = buf; s = buf;
skip(s); skip(s);
while ((t = gettok(&s))) {
while ((t = gettok(&s)) != NULL) {
if (cieq(t, "real")) if (cieq(t, "real"))
flags |= VF_REAL; flags |= VF_REAL;
else if (cieq(t, "complex")) else if (cieq(t, "complex"))
@ -497,7 +497,7 @@ raw_read(char *name)
s = buf; s = buf;
} }
(void) gettok(&s); /* The strchr field. */ (void) gettok(&s); /* The strchr field. */
if ((t = gettok(&s)))
if ((t = gettok(&s)) != NULL)
v->v_name = t; v->v_name = t;
else { else {
fprintf(cp_err, fprintf(cp_err,
@ -516,13 +516,13 @@ raw_read(char *name)
/* Fix the name... */ /* Fix the name... */
if (isdigit(*v->v_name) && (r = ft_typabbrev(v if (isdigit(*v->v_name) && (r = ft_typabbrev(v
->v_type))) {
->v_type)) != NULL) {
(void) sprintf(buf2, "%s(%s)", r, (void) sprintf(buf2, "%s(%s)", r,
v->v_name); v->v_name);
v->v_name = copy(buf2); v->v_name = copy(buf2);
} }
/* Now come the strange options... */ /* Now come the strange options... */
while ((t = gettok(&s))) {
while ((t = gettok(&s)) != NULL) {
if (ciprefix("min=", t)) { if (ciprefix("min=", t)) {
if (sscanf(t + 4, "%lf", if (sscanf(t + 4, "%lf",
&v->v_minsignal) != 1) &v->v_minsignal) != 1)

6
src/frontend/subckt.c

@ -899,7 +899,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, char *sub
if ( ciprefix( ".ic", c->li_line ) || ciprefix( ".nodeset", c->li_line ) ) { if ( ciprefix( ".ic", c->li_line ) || ciprefix( ".nodeset", c->li_line ) ) {
paren_ptr = s = c->li_line; paren_ptr = s = c->li_line;
while ( ( paren_ptr = strstr( paren_ptr, "(" ) ) ) {
while ( ( paren_ptr = strstr( paren_ptr, "(" ) ) != NULL) {
*paren_ptr = '\0'; *paren_ptr = '\0';
paren_ptr++; paren_ptr++;
name = paren_ptr; name = paren_ptr;
@ -1457,7 +1457,7 @@ model_bin_match( char* token, char* model_name )
/* continue evaluation if toeken is part of model_name */ /* continue evaluation if toeken is part of model_name */
if ( strncmp( model_name, token, strlen(token) ) == 0 ) { if ( strncmp( model_name, token, strlen(token) ) == 0 ) {
/* find last dot in model_name */ /* find last dot in model_name */
if ( (dot_char = strrchr( model_name, '.' )) ) {
if ( (dot_char = strrchr( model_name, '.' )) != NULL ) {
flag = TRUE; flag = TRUE;
dot_char++; dot_char++;
while( *dot_char != '\0' ) { while( *dot_char != '\0' ) {
@ -1945,7 +1945,7 @@ devmodtranslate(struct line *deck, char *subname)
for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) { for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) {
i = (int) strlen(wlsub->wl_word); i = (int) strlen(wlsub->wl_word);
j = 0; /* Now, have we a binned model? */ j = 0; /* Now, have we a binned model? */
if ( (dot_char = strstr( wlsub->wl_word, "." )) ) {
if ( (dot_char = strstr( wlsub->wl_word, "." )) != NULL) {
dot_char++; j++; dot_char++; j++;
while( *dot_char != '\0' ) { while( *dot_char != '\0' ) {
if ( !isdigit( *dot_char ) ) { if ( !isdigit( *dot_char ) ) {

6
src/frontend/terminal.c

@ -301,7 +301,7 @@ tcap_init(void)
charbuf = buf2; charbuf = buf2;
if ((s = getenv("TERM"))) {
if ((s = getenv("TERM")) != NULL) {
if (tgetent(tbuf, s) != -1) { if (tgetent(tbuf, s) != -1) {
xsize = tgetnum("co"); xsize = tgetnum("co");
ysize = tgetnum("li"); ysize = tgetnum("li");
@ -316,14 +316,14 @@ tcap_init(void)
#endif #endif
if (!xsize) { if (!xsize) {
if ((s = getenv("COLS")))
if ((s = getenv("COLS")) != NULL)
xsize = atoi(s); xsize = atoi(s);
if (xsize <= 0) if (xsize <= 0)
xsize = 0; xsize = 0;
} }
if (!ysize) { if (!ysize) {
if ((s = getenv("LINES")))
if ((s = getenv("LINES")) != NULL)
ysize = atoi(s); ysize = atoi(s);
if (ysize <= 0) if (ysize <= 0)
ysize = 0; ysize = 0;

8
src/frontend/variable.c

@ -298,7 +298,7 @@ cp_setparse(wordlist *wl)
} else if (wl && (*wl->wl_word == '=')) { } else if (wl && (*wl->wl_word == '=')) {
val = wl->wl_word + 1; val = wl->wl_word + 1;
wl = wl->wl_next; wl = wl->wl_next;
} else if ((s =strchr(name, '='))) {
} else if ((s =strchr(name, '=')) != NULL) {
val = s + 1; val = s + 1;
*s = '\0'; *s = '\0';
if (*val == '\0') { if (*val == '\0') {
@ -667,7 +667,7 @@ cp_variablesubst(wordlist *wlist)
for (wl = wlist; wl; wl = wl->wl_next) { for (wl = wlist; wl; wl = wl->wl_next) {
t = wl->wl_word; t = wl->wl_word;
i = 0; i = 0;
while ((s =strchr(t, cp_dol))) {
while ((s =strchr(t, cp_dol)) != NULL) {
while (t < s) while (t < s)
wbuf[i++] = *t++; wbuf[i++] = *t++;
wbuf[i] = '\0'; wbuf[i] = '\0';
@ -732,7 +732,7 @@ vareval(char *string)
int i, up, low; int i, up, low;
cp_wstrip(string); cp_wstrip(string);
if ((s =strchr(string, '['))) {
if ((s =strchr(string, '[')) != NULL) {
*s = '\0'; *s = '\0';
range = s + 1; range = s + 1;
} }
@ -830,7 +830,7 @@ vareval(char *string)
string = oldstring; string = oldstring;
v = cp_enqvar(string); v = cp_enqvar(string);
} }
if (!v && (s = getenv(string))) {
if (!v && (s = getenv(string)) != NULL) {
wl = alloc(struct wordlist); wl = alloc(struct wordlist);
wl->wl_next = wl->wl_prev = NULL; wl->wl_next = wl->wl_prev = NULL;
wl->wl_word = copy(s); wl->wl_word = copy(s);

2
src/frontend/wdisp/windisp.c

@ -480,7 +480,7 @@ LRESULT CALLBACK PlotWindowProc( HWND hwnd,
WIN_ScreentoData(gr, xe, ye, &fxe, &fye); WIN_ScreentoData(gr, xe, ye, &fxe, &fye);
strncpy(buf2, gr->plotname, sizeof(buf2)); strncpy(buf2, gr->plotname, sizeof(buf2));
if ((t = index(buf2, ':'))) /* strchr */
if ((t = index(buf2, ':')) != NULL) /* strchr */
*t = 0; *t = 0;
if (!eq(plot_cur->pl_typename, buf2)) { if (!eq(plot_cur->pl_typename, buf2)) {

2
src/maths/sparse/spsmp.c

@ -424,7 +424,7 @@ LoadGmin(SMPmatrix *eMatrix, double Gmin)
if (Gmin != 0.0) { if (Gmin != 0.0) {
Diag = Matrix->Diag; Diag = Matrix->Diag;
for (I = Matrix->Size; I > 0; I--) { for (I = Matrix->Size; I > 0; I--) {
if ((diag = Diag[I]))
if ((diag = Diag[I]) != NULL)
diag->Real += Gmin; diag->Real += Gmin;
} }
} }

20
src/misc/hash.c

@ -540,7 +540,7 @@ static NGTABLEPTR _nghash_find_item(NGHASHPTR htable,void * user_key,void * data
} }
/* insert into table only if distinct number */ /* insert into table only if distinct number */
if( (temptr = table[hsum]) ){
if( (temptr = table[hsum]) != NULL ){
/* list started at this hash */ /* list started at this hash */
for(curPtr=temptr ; curPtr ; curPtr=curPtr->next ) { for(curPtr=temptr ; curPtr ; curPtr=curPtr->next ) {
if( htable->compare_func == (void *) NGHASH_DEF_CMP_STR ) { if( htable->compare_func == (void *) NGHASH_DEF_CMP_STR ) {
@ -574,14 +574,14 @@ void * nghash_enumeratek(NGHASHPTR htable, void * *key_return, BOOL start_flag)
NGTABLEPTR current_spot ; /* current place in threaded list */ NGTABLEPTR current_spot ; /* current place in threaded list */
if( start_flag ){ if( start_flag ){
if( (htable->enumeratePtr = htable->thread) ){
if( (htable->enumeratePtr = htable->thread) != NULL ) {
current_spot = htable->enumeratePtr ; current_spot = htable->enumeratePtr ;
*key_return = current_spot->key ; *key_return = current_spot->key ;
return( current_spot->data ) ; return( current_spot->data ) ;
} }
} else { } else {
if( htable->enumeratePtr && if( htable->enumeratePtr &&
(htable->enumeratePtr = htable->enumeratePtr->thread_next) ){
(htable->enumeratePtr = htable->enumeratePtr->thread_next) != NULL ){
current_spot = htable->enumeratePtr ; current_spot = htable->enumeratePtr ;
*key_return = current_spot->key ; *key_return = current_spot->key ;
return( current_spot->data ) ; return( current_spot->data ) ;
@ -597,13 +597,13 @@ void * nghash_enumerate(NGHASHPTR htable,BOOL start_flag)
NGTABLEPTR current_spot ; /* current place in threaded list */ NGTABLEPTR current_spot ; /* current place in threaded list */
if( start_flag ){ if( start_flag ){
if( (htable->enumeratePtr = htable->thread) ){
if( (htable->enumeratePtr = htable->thread) != NULL ){
current_spot = htable->enumeratePtr ; current_spot = htable->enumeratePtr ;
return( current_spot->data ) ; return( current_spot->data ) ;
} }
} else { } else {
if( htable->enumeratePtr && if( htable->enumeratePtr &&
(htable->enumeratePtr = htable->enumeratePtr->thread_next) ){
(htable->enumeratePtr = htable->enumeratePtr->thread_next) != NULL ){
current_spot = htable->enumeratePtr ; current_spot = htable->enumeratePtr ;
return( current_spot->data ) ; return( current_spot->data ) ;
} }
@ -625,14 +625,14 @@ void * nghash_enumeratekRE(NGHASHPTR htable, void * *key_return, NGHASHITERPTR i
return(NULL) ; return(NULL) ;
} }
if(!(iter_p->position)){ if(!(iter_p->position)){
if( (iter_p->position = htable->thread) ){
if( (iter_p->position = htable->thread) != NULL ){
current_spot = iter_p->position ; current_spot = iter_p->position ;
*key_return = current_spot->key ; *key_return = current_spot->key ;
return( current_spot->data ) ; return( current_spot->data ) ;
} }
} else { } else {
if( iter_p->position && if( iter_p->position &&
(iter_p->position = iter_p->position->thread_next) ){
(iter_p->position = iter_p->position->thread_next) != NULL ){
current_spot = iter_p->position ; current_spot = iter_p->position ;
*key_return = current_spot->key ; *key_return = current_spot->key ;
return( current_spot->data ) ; return( current_spot->data ) ;
@ -656,13 +656,13 @@ void * nghash_enumerateRE(NGHASHPTR htable, NGHASHITERPTR iter_p)
return(NULL) ; return(NULL) ;
} }
if(!(iter_p->position)){ if(!(iter_p->position)){
if( (iter_p->position = htable->thread) ){
if( (iter_p->position = htable->thread) != NULL ){
current_spot = iter_p->position ; current_spot = iter_p->position ;
return( current_spot->data ) ; return( current_spot->data ) ;
} }
} else { } else {
if( iter_p->position && if( iter_p->position &&
(iter_p->position = iter_p->position->thread_next) ){
(iter_p->position = iter_p->position->thread_next) != NULL ){
current_spot = iter_p->position ; current_spot = iter_p->position ;
return( current_spot->data ) ; return( current_spot->data ) ;
} }
@ -716,7 +716,7 @@ void nghash_dump(NGHASHPTR htable, void (*print_key) (void *))
fprintf( stderr, "Table is %4.2f%% full\n", fprintf( stderr, "Table is %4.2f%% full\n",
100.0 * (double) htable->num_entries / (double) htable->size ) ; 100.0 * (double) htable->num_entries / (double) htable->size ) ;
for( i = 0 ; i < htable->size ; i++ ) { for( i = 0 ; i < htable->size ; i++ ) {
if( (hptr = table[i]) ){
if( (hptr = table[i]) != NULL ){
fprintf( stderr, " [%5d]:", i ) ; fprintf( stderr, " [%5d]:", i ) ;
count = 0 ; count = 0 ;
for( ; hptr ; hptr=hptr->next ){ for( ; hptr ; hptr=hptr->next ){

2
src/misc/ivars.c

@ -26,7 +26,7 @@ static void
env_overr(char **v, char *e) env_overr(char **v, char *e)
{ {
char *p; char *p;
if (v && e && (p = getenv(e)))
if (v && e && (p = getenv(e)) != NULL)
*v = p; *v = p;
} }

6
src/misc/string.c

@ -28,7 +28,7 @@ copy(const char *str)
{ {
char *p; char *p;
if ((p = TMALLOC(char, strlen(str) + 1)))
if ((p = TMALLOC(char, strlen(str) + 1)) != NULL)
(void) strcpy(p, str); (void) strcpy(p, str);
return(p); return(p);
} }
@ -39,7 +39,7 @@ copy_substring(const char *str, const char *end)
size_t n = (size_t) (end - str); size_t n = (size_t) (end - str);
char *p; char *p;
if ((p = TMALLOC(char, n + 1))) {
if ((p = TMALLOC(char, n + 1)) != NULL) {
(void) strncpy(p, str, n); (void) strncpy(p, str, n);
p[n] = '\0'; p[n] = '\0';
} }
@ -544,7 +544,7 @@ get_comma_separated_values( char *values[], char *str ) {
int count = 0; int count = 0;
char *ptr, *comma_ptr, keep; char *ptr, *comma_ptr, keep;
while ( ( comma_ptr = strstr( str, "," ) ) ) {
while ( ( comma_ptr = strstr( str, "," ) ) != NULL ) {
ptr = comma_ptr - 1; ptr = comma_ptr - 1;
while ( isspace(*ptr) ) ptr--; while ( isspace(*ptr) ) ptr--;
ptr++; keep = *ptr; *ptr = '\0'; ptr++; keep = *ptr; *ptr = '\0';

2
src/xspice/evt/evtdump.c

@ -292,7 +292,7 @@ void EVTdump(
if(node_dict[index].send) { if(node_dict[index].send) {
/* Scan through new events and send the data for each event */ /* Scan through new events and send the data for each event */
here = *(node_data->last_step[index]); here = *(node_data->last_step[index]);
while((here = here->next)) {
while((here = here->next) != NULL) {
EVTsend_line(node_dict[index].ipc_index, EVTsend_line(node_dict[index].ipc_index,
here->step, here->step,
here->node_value, here->node_value,

Loading…
Cancel
Save