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

This commit is contained in:
rlar 2010-11-19 18:52:44 +00:00
parent ad8ad56955
commit e6c30efe46
29 changed files with 94 additions and 90 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -189,7 +189,7 @@ inp_pathopen(char *name, char *mode)
/* add file name */
strcat(buf2, name);
/* try to open file */
if ((fp = fopen(buf2, mode)))
if ((fp = fopen(buf2, mode)) != NULL)
return (fp);
}
#endif
@ -219,7 +219,7 @@ inp_pathopen(char *name, char *mode)
controlled_exit(EXIT_FAILURE);
}
}
if ((fp = fopen(buf, mode)))
if ((fp = fopen(buf, mode)) != NULL)
return (fp);
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 (( *gnd == '*' ) || (strstr( gnd, "gnd" ) == NULL)) { c = c->li_next; continue; }
// 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) == ',' ) &&
( 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 ) {
str_ptr1 = line = c->li_line;
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++;
keep = *str_ptr1;
*str_ptr1 = '\0';
@ -539,7 +539,7 @@ get_instance_subckt( char *line )
char keep = ' ';
// see if instance has parameters
if ( ( equal_ptr = strstr( line, "=" ) ) ) {
if ((equal_ptr = strstr(line, "=")) != NULL) {
end_ptr = equal_ptr - 1;
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;
if ( strncmp( model_name, token, strlen(token) ) == 0 ) {
if ( (dot_char = strstr( model_name, "." )) ) {
if ((dot_char = strstr( model_name, "." )) != NULL) {
flag = TRUE;
dot_char++;
while( *dot_char != '\0' ) {
@ -951,7 +951,7 @@ inp_fix_ternary_operator_str( char *line )
str_ptr2 = colon - 1;
while ( isspace(*str_ptr2) ) str_ptr2--;
}
else if ( ( colon = strstr( str_ptr, ":" ) ) ) {
else if ((colon = strstr( str_ptr, ":" )) != NULL) {
str_ptr2 = colon - 1;
while ( isspace(*str_ptr2) ) str_ptr2--;
}
@ -992,7 +992,7 @@ inp_fix_ternary_operator_str( char *line )
*str_ptr2 = keep;
}
else {
if ( ( str_ptr2 = strstr( str_ptr, "}" ) ) ) {
if ((str_ptr2 = strstr(str_ptr, "}")) != NULL) {
*str_ptr2 = '\0';
else_str = inp_fix_ternary_operator_str(strdup(str_ptr));
*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 */
#else
while ((buffer = readline(fp))) {
while ((buffer = readline(fp)) != NULL) {
#endif
#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_orig = line_number_orig++;
tfree(buffer);
} /* end while ((buffer = readline(fp))) */
} /* end while ((buffer = readline(fp)) != NULL) */
if (!end) { /* No stuff here */
*data = NULL;
@ -1849,7 +1849,7 @@ inp_fix_subckt( char *s )
head = alloc(struct line);
/* create list of parameters that need to get sorted */
while ( *beg && (ptr1 = strstr( beg, "=" ) ) ) {
while ( *beg && (ptr1 = strstr( beg, "=" )) != NULL ) {
ptr2 = ptr1+1;
ptr1--;
while ( isspace(*ptr1) ) ptr1--;
@ -2131,7 +2131,7 @@ inp_get_params( char *line, char *param_names[], char *param_values[] )
char keep;
bool is_expression = FALSE;
while ( ( equal_ptr = strstr( line, "=" ) ) ) {
while ( (equal_ptr = strstr( line, "=" )) != NULL ) {
// check for equality '=='
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;
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 */
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 keep;
while ( ( open_paren_ptr = strstr( search_ptr, "(" ) ) ) {
while ( (open_paren_ptr = strstr( search_ptr, "(" )) != NULL ) {
fcn_name = open_paren_ptr;
if ( open_paren_ptr != search_ptr) {
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 */
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
// 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 keep;
if ( ( equal_ptr = strstr( line, "=" ) ) )
if (( equal_ptr = strstr( line, "=" ) ) != NULL )
{
equal_ptr--;
while ( isspace(*equal_ptr) ) equal_ptr--;
@ -3001,7 +3001,7 @@ get_param_str( char *line )
{
char *equal_ptr;
if ( ( equal_ptr = strstr( line, "=" ) ) ) {
if (( equal_ptr = strstr( line, "=" ) ) != NULL ) {
equal_ptr++;
while ( isspace(*equal_ptr) ) equal_ptr++;
return equal_ptr;
@ -3089,7 +3089,7 @@ get_number_terminals( char *c )
name[i] = gettok_instance(&c);
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 ((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 (eq(name[i], ",")) j++;
i++;
@ -3218,7 +3218,7 @@ inp_sort_params( struct line *start_card, struct line *end_card, struct line *ca
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 */
/* 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 ( ( 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 */
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 ) )
{
counter = 0;
while ( ( equal_ptr = strstr( curr_line, "=" ) ) ) {
while (( equal_ptr = strstr( curr_line, "=" ) ) != NULL ) {
// check for equality '=='
if ( *(equal_ptr+1) == '=' ) { curr_line = equal_ptr+2; continue; }
// check for '!=', '<=', '>='
@ -3487,7 +3487,7 @@ inp_split_multi_param_lines( struct line *deck, int line_num )
// need to split multi param line
curr_line = card->li_line;
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 '=='
if ( *(equal_ptr+1) == '=' ) { curr_line = equal_ptr+2; continue; }

View File

@ -83,7 +83,7 @@ com_meas(wordlist *wl) {
}
}
/* 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;
if (!cieq(vec_found, "LAST")) {
INPevaluate( &vec_found, &err, 1 );
@ -162,7 +162,7 @@ get_double_value(
*value = INPevaluate( &junk, &err, 1 );
} else {
if ( (equal_ptr = strstr( token, "=" )) ) {
if ( (equal_ptr = strstr( token, "=" )) != NULL ) {
equal_ptr += 1;
*value = INPevaluate( &equal_ptr, &err, 1 );
} else {

View File

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

View File

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

View File

@ -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 */
j = j + (int) strlen(token) + 1;
if (strcmp(token, spice_dstring_value(&subname))) {
while ((token = strtok(NULL, " "))) {
while ((token = strtok(NULL, " ")) != NULL) {
if (!strcmp(token, spice_dstring_value(&subname))) {
found = 1;
break;

View File

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

View File

@ -815,7 +815,7 @@ fileInit_pass2(runDesc *run)
if ( type == SV_CURRENT ) {
branch = NULL;
if ( (branch = strstr( name, "#branch" )) ) {
if ( (branch = strstr( name, "#branch" )) != NULL ) {
*branch = '\0';
}
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;
if ((s =strchr(n1, '('))) {
if ((s =strchr(n1, '(')) != NULL) {
strcpy(buf1, s);
if (!(s =strchr(buf1, ')')))
return FALSE;
*s = '\0';
n1 = buf1;
}
if ((s =strchr(n2, '('))) {
if ((s =strchr(n2, '(')) != NULL) {
strcpy(buf2, s);
if (!(s =strchr(buf2, ')')))
return FALSE;
@ -1119,7 +1119,7 @@ getSpecial(dataDesc *desc, runDesc *run, IFvalue *val)
&selector) == OK) {
desc->type &= (IF_REAL | IF_COMPLEX); /* mask out other bits */
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 */
desc->type = IF_REAL;
if (vv->va_type == CP_REAL)

View File

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

View File

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

View File

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

View File

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

View File

@ -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) {
if ( strcmp( ft_typenames(v->v_type), "current" ) == 0 ) {
branch = NULL;
if ( (branch = strstr( v->v_name, "#branch" )) ) {
if ((branch = strstr( v->v_name, "#branch" )) != NULL) {
*branch = '\0';
}
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)) {
s = buf;
skip(s);
while ((t = gettok(&s))) {
while ((t = gettok(&s)) != NULL) {
if (cieq(t, "real"))
flags |= VF_REAL;
else if (cieq(t, "complex"))
@ -497,7 +497,7 @@ raw_read(char *name)
s = buf;
}
(void) gettok(&s); /* The strchr field. */
if ((t = gettok(&s)))
if ((t = gettok(&s)) != NULL)
v->v_name = t;
else {
fprintf(cp_err,
@ -516,13 +516,13 @@ raw_read(char *name)
/* Fix the name... */
if (isdigit(*v->v_name) && (r = ft_typabbrev(v
->v_type))) {
->v_type)) != NULL) {
(void) sprintf(buf2, "%s(%s)", r,
v->v_name);
v->v_name = copy(buf2);
}
/* Now come the strange options... */
while ((t = gettok(&s))) {
while ((t = gettok(&s)) != NULL) {
if (ciprefix("min=", t)) {
if (sscanf(t + 4, "%lf",
&v->v_minsignal) != 1)

View File

@ -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 ) ) {
paren_ptr = s = c->li_line;
while ( ( paren_ptr = strstr( paren_ptr, "(" ) ) ) {
while ( ( paren_ptr = strstr( paren_ptr, "(" ) ) != NULL) {
*paren_ptr = '\0';
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 */
if ( strncmp( model_name, token, strlen(token) ) == 0 ) {
/* find last dot in model_name */
if ( (dot_char = strrchr( model_name, '.' )) ) {
if ( (dot_char = strrchr( model_name, '.' )) != NULL ) {
flag = TRUE;
dot_char++;
while( *dot_char != '\0' ) {
@ -1945,7 +1945,7 @@ devmodtranslate(struct line *deck, char *subname)
for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) {
i = (int) strlen(wlsub->wl_word);
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++;
while( *dot_char != '\0' ) {
if ( !isdigit( *dot_char ) ) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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