Apply badzero.cocci, badnull.cocci and badnull2.cocci

Since badzero.cocci depends on coccinelle knowledge about a variable being a pointer
and about a function returning a pointer, maybe there are false negatives.



SVN revision: 51092
This commit is contained in:
Lucas De Marchi 2010-08-13 17:04:13 +00:00
parent 4d84d3155c
commit 4d4401c5d3
33 changed files with 154 additions and 154 deletions

View File

@ -322,7 +322,7 @@ main(int argc, char **argv)
else
docdir = strdup(argv[i]);
}
if (docdir == NULL)
if (!docdir)
docdir = strdup(doxdir);
s = EMALLOC(char, strlen(docdir) + strlen(docfile) + 2 + 20);
@ -342,7 +342,7 @@ main(int argc, char **argv)
LoadFile(s, docfile);
if ((disp = XOpenDisplay(NULL)) == NULL)
if (!(disp = XOpenDisplay(NULL)))
{
printf("%s: Cannot open X display.\n", argv[0]);
exit(0);

View File

@ -99,7 +99,7 @@ TextStateLoadFont(TextState * ts)
}
#if USE_XFONT
if ((!ts->xfont) && (strchr(ts->fontname, ',') == NULL))
if ((!ts->xfont) && (!strchr(ts->fontname, ',')))
{
ts->xfont = XLoadQueryFont(disp, ts->fontname);
if (ts->xfont)

View File

@ -98,7 +98,7 @@ Efont_load(const char *file, int size)
Esnprintf(s, sizeof(s), "%s/%d", file, size);
ff = imlib_load_font(s);
if (ff == NULL)
if (!ff)
return NULL;
f = EMALLOC(Efont, 1);

View File

@ -35,7 +35,7 @@ static Window my_win, comms_win;
static void
process_line(char *line)
{
if (line == NULL)
if (!line)
exit(0);
if (*line == '\0')
return;
@ -166,7 +166,7 @@ main(int argc, char **argv)
/* CommsSend(e, "set pixmap 0"); */
#endif
if (command == NULL && i < argc)
if (!command && i < argc)
{
mode = 1;
len = 0;

View File

@ -37,7 +37,7 @@ xmalloc(unsigned size)
{
char *ptr = (char *)malloc(size);
if (ptr != NULL)
if (ptr)
return (ptr);
memory_full();
/*NOTREACHED */
@ -49,7 +49,7 @@ xrealloc(void *old, unsigned size)
{
char *ptr = (char *)realloc(old, size);
if (ptr == NULL)
if (!ptr)
memory_full();
return ptr;
}
@ -59,7 +59,7 @@ xcalloc(unsigned number, unsigned size)
{
char *ptr = (char *)calloc(number, size);
if (ptr == NULL)
if (!ptr)
memory_full();
return ptr;
}

View File

@ -44,7 +44,7 @@ cpp_print_containing_files(cpp_reader * pfile)
ip = cpp_file_buffer(pfile);
/* Give up if we don't find a source file. */
if (ip == NULL)
if (!ip)
return;
/* Find the other, outer source files. */
@ -53,7 +53,7 @@ cpp_print_containing_files(cpp_reader * pfile)
long line, col;
cpp_buf_line_and_col(ip, &line, &col);
if (ip->fname != NULL)
if (ip->fname)
{
if (first)
{

View File

@ -300,7 +300,7 @@ cpp_lex(struct operation *op, cpp_reader * pfile)
case CPP_VSPACE:
case CPP_POP:
if (CPP_BUFFER(pfile)->fname != NULL)
if (CPP_BUFFER(pfile)->fname)
{
op->op = 0;
break;
@ -449,7 +449,7 @@ cpp_lex(struct operation *op, cpp_reader * pfile)
/* See if it is a special token of length 2. */
if (tok_start + 2 == tok_end)
{
for (toktab = tokentab2; toktab->oper != NULL; toktab++)
for (toktab = tokentab2; toktab->oper; toktab++)
if (tok_start[0] == toktab->oper[0]
&& tok_start[1] == toktab->oper[1])
break;

View File

@ -101,9 +101,9 @@ void
delete_macro(HASHNODE * hp)
{
if (hp->prev != NULL)
if (hp->prev)
hp->prev->next = hp->next;
if (hp->next != NULL)
if (hp->next)
hp->next->prev = hp->prev;
/* make sure that the bucket chain header that
@ -116,7 +116,7 @@ delete_macro(HASHNODE * hp)
DEFINITION *d = hp->value.defn;
struct reflist *ap, *nextap;
for (ap = d->pattern; ap != NULL; ap = nextap)
for (ap = d->pattern; ap; ap = nextap)
{
nextap = ap->next;
free(ap);
@ -166,7 +166,7 @@ install(const char *name, int len, enum node_type type, int ivalue, char *value,
hp->next = hashtab[bucket];
hashtab[bucket] = hp;
hp->prev = NULL;
if (hp->next != NULL)
if (hp->next)
hp->next->prev = hp;
hp->type = type;
hp->length = len;

View File

@ -690,12 +690,12 @@ append_include_chain(cpp_reader * pfile, file_name_list * first,
if (!first || !last)
return;
if (opts->include == NULL)
if (!opts->include)
opts->include = first;
else
opts->last_include->next = first;
if (opts->first_bracket_include == NULL)
if (!opts->first_bracket_include)
opts->first_bracket_include = first;
for (dir = first;; dir = dir->next)
@ -1385,7 +1385,7 @@ collect_expansion(cpp_reader * pfile, unsigned char *buf, unsigned char *limit,
{
struct arglist *arg;
for (arg = arglist; arg != NULL; arg = arg->next)
for (arg = arglist; arg; arg = arg->next)
{
reflist *tpat;
@ -1425,7 +1425,7 @@ collect_expansion(cpp_reader * pfile, unsigned char *buf, unsigned char *limit,
? expected_delimiter != '\0'
: stringify == id_beg);
if (endpat == NULL)
if (!endpat)
defn->pattern = tpat;
else
endpat->next = tpat;
@ -1596,7 +1596,7 @@ create_definition(MACRODEF * mdef, unsigned char *buf, unsigned char *limit,
{
struct arglist *otemp;
for (otemp = temp->next; otemp != NULL; otemp = otemp->next)
for (otemp = temp->next; otemp; otemp = otemp->next)
if (temp->length == otemp->length &&
strncmp((const char *)temp->name,
(const char *)otemp->name, temp->length) == 0)
@ -1632,7 +1632,7 @@ create_definition(MACRODEF * mdef, unsigned char *buf, unsigned char *limit,
{
memcpy(&defn->args.argnames[i], temp->name, temp->length);
i += temp->length;
if (temp->next != NULL)
if (temp->next)
{
defn->args.argnames[i++] = ',';
defn->args.argnames[i++] = ' ';
@ -1851,13 +1851,13 @@ do_define(cpp_reader * pfile, struct directive *keyword,
MACRODEF mdef;
HASHNODE *hp;
create_definition(&mdef, buf, limit, pfile, keyword == NULL);
if (mdef.defn == NULL)
create_definition(&mdef, buf, limit, pfile, !keyword);
if (!mdef.defn)
return 1;
hashcode = hashf(mdef.symnam, mdef.symlen, HASHSIZE);
if ((hp = cpp_lookup(mdef.symnam, mdef.symlen, hashcode)) != NULL)
if ((hp = cpp_lookup(mdef.symnam, mdef.symlen, hashcode)))
{
int ok = 0;
@ -2061,7 +2061,7 @@ update_position(cpp_buffer * pbuf)
unsigned char *new_pos = pbuf->cur;
struct parse_marker *mark;
for (mark = pbuf->marks; mark != NULL; mark = mark->next)
for (mark = pbuf->marks; mark; mark = mark->next)
{
if (pbuf->buf + mark->position < new_pos)
new_pos = pbuf->buf + mark->position;
@ -2075,7 +2075,7 @@ cpp_buf_line_and_col(cpp_buffer * pbuf, long *linep, long *colp)
{
long dummy;
if (colp == NULL)
if (!colp)
colp = &dummy;
if (pbuf)
{
@ -2098,7 +2098,7 @@ cpp_file_buffer(cpp_reader * pfile)
cpp_buffer *ip = CPP_BUFFER(pfile);
for (; ip != CPP_NULL_BUFFER(pfile); ip = CPP_PREV_BUFFER(ip))
if (ip->fname != NULL)
if (ip->fname)
return ip;
return NULL;
}
@ -2134,7 +2134,7 @@ output_line_command(cpp_reader * pfile, int conditional,
cpp_buffer *ip = CPP_BUFFER(pfile);
if (CPP_OPTIONS(pfile)->no_line_commands
|| ip->fname == NULL || CPP_OPTIONS(pfile)->no_output)
|| !ip->fname || CPP_OPTIONS(pfile)->no_output)
{
return;
}
@ -2342,12 +2342,12 @@ special_symbol(HASHNODE * hp, cpp_reader * pfile)
for (ip = CPP_BUFFER(pfile);; ip = CPP_PREV_BUFFER(ip))
{
if (ip == NULL)
if (!ip)
{
cpp_error(pfile, "cccp error: not in any file?!");
return; /* the show must go on */
}
if (ip->fname != NULL)
if (ip->fname)
break;
}
@ -2374,8 +2374,8 @@ special_symbol(HASHNODE * hp, cpp_reader * pfile)
case T_INCLUDE_LEVEL:
true_indepth = 0;
for (ip = CPP_BUFFER(pfile); ip != NULL; ip = CPP_PREV_BUFFER(ip))
if (ip->fname != NULL)
for (ip = CPP_BUFFER(pfile); ip; ip = CPP_PREV_BUFFER(ip))
if (ip->fname)
true_indepth++;
bufx = (char *)alloca(8); /* Eight bytes ought to be more than enough */
@ -2829,7 +2829,7 @@ macroexpand(cpp_reader * pfile, HASHNODE * hp)
/* Compute length in characters of the macro's expansion.
* Also count number of times each arg is used. */
xbuf_len = defn->length;
for (ap = defn->pattern; ap != NULL; ap = ap->next)
for (ap = defn->pattern; ap; ap = ap->next)
{
if (ap->stringify)
{
@ -2946,7 +2946,7 @@ macroexpand(cpp_reader * pfile, HASHNODE * hp)
* OFFSET is the index in the definition
* of where we are copying from. */
offset = totlen = 0;
for (last_ap = NULL, ap = defn->pattern; ap != NULL;
for (last_ap = NULL, ap = defn->pattern; ap;
last_ap = ap, ap = ap->next)
{
struct argdata *arg = &args[ap->argno];
@ -2960,7 +2960,7 @@ macroexpand(cpp_reader * pfile, HASHNODE * hp)
* delete the last run of nonwhite chars. */
if (rest_zero && totlen > count_before
&& ((ap->rest_args && ap->raw_before)
|| (last_ap != NULL && last_ap->rest_args
|| (last_ap && last_ap->rest_args
&& last_ap->raw_after)))
{
/* Delete final whitespace. */
@ -3066,7 +3066,7 @@ macroexpand(cpp_reader * pfile, HASHNODE * hp)
/* if we've reached the end of the macro */
if (exp[i] == ')')
rest_zero = 0;
if (!(rest_zero && last_ap != NULL && last_ap->rest_args
if (!(rest_zero && last_ap && last_ap->rest_args
&& last_ap->raw_after))
xbuf[totlen++] = exp[i];
}
@ -3240,12 +3240,12 @@ do_include(cpp_reader * pfile, struct directive *keyword,
/* We have "filename". Figure out directory this source
* file is coming from and put it on the front of the list. */
for (fp = CPP_BUFFER(pfile); fp != NULL; fp = CPP_PREV_BUFFER(fp))
for (fp = CPP_BUFFER(pfile); fp; fp = CPP_PREV_BUFFER(fp))
{
int n;
const char *ep, *nam;
if ((nam = fp->nominal_fname) != NULL)
if ((nam = fp->nominal_fname))
{
/* Found a named file. Figure out dir of the file,
* and put it in front of the search list. */
@ -3255,14 +3255,14 @@ do_include(cpp_reader * pfile, struct directive *keyword,
ep = strrchr(nam, '/');
#else /* VMS */
ep = strrchr(nam, ']');
if (ep == NULL)
if (!ep)
ep = strrchr(nam, '>');
if (ep == NULL)
if (!ep)
ep = strrchr(nam, ':');
if (ep != NULL)
if (ep)
ep++;
#endif /* VMS */
if (ep != NULL)
if (ep)
{
n = ep - nam;
dsp[0].fname = (char *)alloca(n + 1);
@ -3305,8 +3305,8 @@ do_include(cpp_reader * pfile, struct directive *keyword,
{
cpp_buffer *fp;
for (fp = CPP_BUFFER(pfile); fp != NULL; fp = CPP_PREV_BUFFER(fp))
if (fp->fname != NULL)
for (fp = CPP_BUFFER(pfile); fp; fp = CPP_PREV_BUFFER(fp))
if (fp->fname)
{
/* fp->dir is null if the containing file was specified with
* an absolute file name. In that case, don't skip anything. */
@ -3388,7 +3388,7 @@ do_include(cpp_reader * pfile, struct directive *keyword,
strncpy(fname, fbeg, flen);
fname[flen] = 0;
/* if it's '#include filename', add the missing .h */
if (strchr(fname, '.') == NULL)
if (!strchr(fname, '.'))
{
strcat(fname, ".h");
}
@ -3495,7 +3495,7 @@ do_include(cpp_reader * pfile, struct directive *keyword,
break; /* This file was included before. */
}
if (ptr == NULL)
if (!ptr)
{
/* This is the first time for this file. */
/* Add it to list of files included. */
@ -3519,7 +3519,7 @@ do_include(cpp_reader * pfile, struct directive *keyword,
{
cpp_buffer *buf = CPP_BUFFER(pfile);
while ((buf = CPP_PREV_BUFFER(buf)) != NULL)
while ((buf = CPP_PREV_BUFFER(buf)))
putc('.', stderr);
fprintf(stderr, "%s\n", fname);
}
@ -3622,7 +3622,7 @@ assertion_install(cpp_reader * pfile, const char *name, int len, int hash)
hp->next = pfile->assertion_hashtab[bucket];
pfile->assertion_hashtab[bucket] = hp;
hp->prev = NULL;
if (hp->next != NULL)
if (hp->next)
hp->next->prev = hp;
hp->length = len;
hp->value = 0;
@ -3662,9 +3662,9 @@ delete_assertion(ASSERTION_HASHNODE * hp)
{
struct tokenlist_list *tail;
if (hp->prev != NULL)
if (hp->prev)
hp->prev->next = hp->next;
if (hp->next != NULL)
if (hp->next)
hp->next->prev = hp->prev;
for (tail = hp->value; tail;)
@ -3783,7 +3783,7 @@ do_line(cpp_reader * pfile, struct directive *keyword,
* into a null-terminated string. Do this in place. */
end_name =
convert_string(pfile, fname, fname, (char *)CPP_PWRITTEN(pfile), 1);
if (end_name == NULL)
if (!end_name)
{
cpp_error(pfile, "invalid format `#line' command");
goto bad_line_directive;
@ -3828,14 +3828,14 @@ do_line(cpp_reader * pfile, struct directive *keyword,
}
}
hash_bucket = &fname_table[hashf(fname, fname_length, FNAME_HASHSIZE)];
for (hp = *hash_bucket; hp != NULL; hp = hp->next)
for (hp = *hash_bucket; hp; hp = hp->next)
if (hp->length == fname_length &&
strncmp(hp->value.cpval, fname, fname_length) == 0)
{
ip->nominal_fname = hp->value.cpval;
break;
}
if (hp == NULL)
if (!hp)
{
/* Didn't find it; cons up a new one. */
hp = (HASHNODE *) xcalloc(1, sizeof(HASHNODE) + fname_length + 1);
@ -3878,7 +3878,7 @@ do_undef(cpp_reader * pfile, struct directive *keyword, unsigned char *buf,
SKIP_WHITE_SPACE(buf);
sym_length = check_macro_name(pfile, buf, "macro");
while ((hp = cpp_lookup((const char *)buf, sym_length, -1)) != NULL)
while ((hp = cpp_lookup((const char *)buf, sym_length, -1)))
{
/* If we are generating additional info for debugging (with -g) we
* need to pass through all effective #undef commands. */
@ -3952,9 +3952,9 @@ do_once(cpp_reader * pfile)
for (ip = CPP_BUFFER(pfile);; ip = CPP_PREV_BUFFER(ip))
{
if (ip == NULL)
if (!ip)
return 0;
if (ip->fname != NULL)
if (ip->fname)
break;
}
@ -4025,7 +4025,7 @@ do_pragma(cpp_reader * pfile, struct directive *keyword, unsigned char *buf,
fname = p + 1;
p = strchr(fname, '\"');
fname_len =
(int)(((int)(p != NULL)) ? ((int)(p - fname))
(int)(((int)(p)) ? ((int)(p - fname))
: ((int)(strlen(fname))));
for (ptr = pfile->all_include_files; ptr; ptr = ptr->next)
@ -4089,8 +4089,8 @@ do_elif(cpp_reader * pfile, struct directive *keyword, unsigned char *buf,
if (pfile->if_stack->type != T_IF && pfile->if_stack->type != T_ELIF)
{
cpp_error(pfile, "`#elif' after `#else'");
if (pfile->if_stack->fname != NULL
&& CPP_BUFFER(pfile)->fname != NULL
if (pfile->if_stack->fname
&& CPP_BUFFER(pfile)->fname
&& strcmp(pfile->if_stack->fname,
CPP_BUFFER(pfile)->nominal_fname) != 0)
fprintf(stderr, ", file %s", pfile->if_stack->fname);
@ -4184,7 +4184,7 @@ do_xifdef(cpp_reader * pfile, struct directive *keyword, unsigned char *unused1,
{
HASHNODE *hp = cpp_lookup(ident, ident_length, -1);
skip = (hp == NULL) ^ (keyword->type == T_IFNDEF);
skip = (!hp) ^ (keyword->type == T_IFNDEF);
if (start_of_file && !skip)
{
control_macro = (unsigned char *)xmalloc(ident_length + 1);
@ -4483,7 +4483,7 @@ do_endif(cpp_reader * pfile, struct directive *keyword, unsigned char *buf,
IF_STACK_FRAME *temp = pfile->if_stack;
pfile->if_stack = temp->next;
if (temp->control_macro != NULL)
if (temp->control_macro)
{
/* This #endif matched a #ifndef at the start of the file.
* See if it is at the end of the file. */
@ -4514,7 +4514,7 @@ do_endif(cpp_reader * pfile, struct directive *keyword, unsigned char *buf,
{
file_name_list *ifile = pfile->all_include_files;
for (; ifile != NULL; ifile = ifile->next)
for (; ifile; ifile = ifile->next)
{
if (!strcmp(ifile->fname, CPP_BUFFER(pfile)->fname))
{
@ -4577,7 +4577,7 @@ cpp_get_token(cpp_reader * pfile)
cpp_buffer *next_buf = CPP_PREV_BUFFER(CPP_BUFFER(pfile));
CPP_BUFFER(pfile)->seen_eof = 1;
if (CPP_BUFFER(pfile)->nominal_fname && next_buf != NULL)
if (CPP_BUFFER(pfile)->nominal_fname && next_buf)
{
/* We're about to return from an #include file.
* Emit #line information now (as part of the CPP_POP) result.
@ -5693,7 +5693,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
* but that seems pointless: it comes before them, so it overrides them
* anyway. */
p = (char *)getenv("CPATH");
if (p != NULL && !opts->no_standard_includes)
if (p && !opts->no_standard_includes)
path_include(pfile, p);
/* Now that dollars_in_ident is known, initialize is_idchar. */
@ -5702,7 +5702,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
/* Do partial setup of input buffer for the sake of generating
* early #line directives (when -g is in effect). */
fp = cpp_push_buffer(pfile, NULL, 0);
if (opts->in_fname == NULL)
if (!opts->in_fname)
opts->in_fname = "";
fp->nominal_fname = fp->fname = opts->in_fname;
fp->lineno = 0;
@ -5801,7 +5801,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
for (pend = opts->pending; pend; pend = pend->next)
{
if (pend->cmd != NULL && pend->cmd[0] == '-')
if (pend->cmd && pend->cmd[0] == '-')
{
switch (pend->cmd[1])
{
@ -5914,7 +5914,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
}
/* Search "translated" versions of GNU directories.
* These have /usr/local/lib/gcc... replaced by specd_prefix. */
if (specd_prefix != NULL && default_len != 0)
if (specd_prefix && default_len != 0)
for (di = include_defaults; di->fname; di++)
{
/* Some standard dirs are only for C++. */
@ -5942,7 +5942,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
new_->c_system_include_path = !di->cxx_aware;
new_->got_name_map = 0;
append_include_chain(pfile, new_, new_);
if (opts->first_system_include == NULL)
if (!opts->first_system_include)
opts->first_system_include = new_;
}
}
@ -5962,14 +5962,14 @@ push_parse_file(cpp_reader * pfile, const char *fname)
new_->fname = (char *)di->fname;
new_->got_name_map = 0;
append_include_chain(pfile, new_, new_);
if (opts->first_system_include == NULL)
if (!opts->first_system_include)
opts->first_system_include = new_;
}
}
}
/* Tack the after_include chain at the end of the include chain. */
append_include_chain(pfile, opts->after_include, opts->last_after_include);
if (opts->first_system_include == NULL)
if (!opts->first_system_include)
opts->first_system_include = opts->after_include;
/* With -v, print the list of dirs to search. */
@ -5994,7 +5994,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
pfile->no_record_file++;
for (pend = opts->pending; pend; pend = pend->next)
{
if (pend->cmd != NULL && strcmp(pend->cmd, "-imacros") == 0)
if (pend->cmd && strcmp(pend->cmd, "-imacros") == 0)
{
int fd = open(pend->arg, O_RDONLY, 0666);
@ -6013,7 +6013,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
/* Copy the entire contents of the main input file into
* the stacked input buffer previously allocated for it. */
if (fname == NULL || *fname == 0)
if (!fname || *fname == 0)
{
fname = "";
f = 0;
@ -6041,7 +6041,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
char *s;
char *output_file;
if (spec == NULL)
if (!spec)
{
spec = getenv("SUNPRO_DEPENDENCIES");
opts->print_deps = 2;
@ -6090,9 +6090,9 @@ push_parse_file(cpp_reader * pfile, const char *fname)
int len;
/* Discard all directory prefixes from filename. */
if ((q = (char *)strrchr(opts->in_fname, '/')) != NULL
if ((q = (char *)strrchr(opts->in_fname, '/'))
#ifdef DIR_SEPARATOR
&& (q = strrchr(opts->in_fname, DIR_SEPARATOR)) != NULL
&& (q = strrchr(opts->in_fname, DIR_SEPARATOR))
#endif
)
++q;
@ -6138,7 +6138,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
opts->pending = nreverse_pending(opts->pending);
for (pend = opts->pending; pend; pend = pend->next)
{
if (pend->cmd != NULL && strcmp(pend->cmd, "-include") == 0)
if (pend->cmd && strcmp(pend->cmd, "-include") == 0)
{
int fd = open(pend->arg, O_RDONLY, 0666);
@ -6228,9 +6228,9 @@ cpp_handle_options(cpp_reader * pfile, int argc, char **argv)
{
if (argv[i][0] != '-')
{
if (opts->out_fname != NULL)
if (opts->out_fname)
cpp_fatal("Usage: %s [switches] input output", argv[0]);
else if (opts->in_fname != NULL)
else if (opts->in_fname)
opts->out_fname = argv[i];
else
opts->in_fname = argv[i];
@ -6278,7 +6278,7 @@ cpp_handle_options(cpp_reader * pfile, int argc, char **argv)
strcpy(dirtmp->fname, argv[++i]);
dirtmp->got_name_map = 0;
if (opts->before_system == NULL)
if (!opts->before_system)
opts->before_system = dirtmp;
else
opts->last_before_system->next = dirtmp;
@ -6291,7 +6291,7 @@ cpp_handle_options(cpp_reader * pfile, int argc, char **argv)
file_name_list *dirtmp;
char *prefix;
if (opts->include_prefix != NULL)
if (opts->include_prefix)
prefix = opts->include_prefix;
else
{
@ -6318,7 +6318,7 @@ cpp_handle_options(cpp_reader * pfile, int argc, char **argv)
strcat(dirtmp->fname, argv[++i]);
dirtmp->got_name_map = 0;
if (opts->after_include == NULL)
if (!opts->after_include)
opts->after_include = dirtmp;
else
opts->last_after_include->next = dirtmp;
@ -6331,7 +6331,7 @@ cpp_handle_options(cpp_reader * pfile, int argc, char **argv)
file_name_list *dirtmp;
char *prefix;
if (opts->include_prefix != NULL)
if (opts->include_prefix)
prefix = opts->include_prefix;
else
{
@ -6378,7 +6378,7 @@ cpp_handle_options(cpp_reader * pfile, int argc, char **argv)
dirtmp->fname = argv[++i];
dirtmp->got_name_map = 0;
if (opts->after_include == NULL)
if (!opts->after_include)
opts->after_include = dirtmp;
else
opts->last_after_include->next = dirtmp;
@ -6387,7 +6387,7 @@ cpp_handle_options(cpp_reader * pfile, int argc, char **argv)
break;
case 'o':
if (opts->out_fname != NULL)
if (opts->out_fname)
cpp_fatal("Output filename specified twice");
if (i + 1 == argc)
cpp_fatal("Filename missing after -o option");
@ -6600,7 +6600,7 @@ cpp_handle_options(cpp_reader * pfile, int argc, char **argv)
* that were passed automatically in from GCC. */
opts->inhibit_predefs = 1;
for (ptr = &opts->pending; *ptr != NULL;)
for (ptr = &opts->pending; *ptr;)
{
struct cpp_pending *pend = *ptr;
@ -6695,12 +6695,12 @@ cpp_handle_options(cpp_reader * pfile, int argc, char **argv)
break;
case '\0': /* JF handle '-' as file name meaning stdin or stdout */
if (opts->in_fname == NULL)
if (!opts->in_fname)
{
opts->in_fname = "";
break;
}
else if (opts->out_fname == NULL)
else if (!opts->out_fname)
{
opts->out_fname = "";
break;
@ -6729,9 +6729,9 @@ cpp_finish(cpp_reader * pfile)
const char *deps_mode =
opts->print_deps_append ? "a" : "w";
if (opts->deps_file == NULL)
if (!opts->deps_file)
deps_stream = stdout;
else if ((deps_stream = fopen(opts->deps_file, deps_mode)) == 0)
else if (!(deps_stream = fopen(opts->deps_file, deps_mode)))
cpp_pfatal_with_name(pfile, opts->deps_file);
fputs(pfile->deps_buffer, deps_stream);
putc('\n', deps_stream);
@ -6779,7 +6779,7 @@ do_assert(cpp_reader * pfile, struct directive *keyword, unsigned char *buf,
tokens = read_token_list(pfile, &error_flag);
if (error_flag)
goto error;
if (tokens == NULL)
if (!tokens)
{
cpp_error(pfile, "empty token-sequence in `#assert'");
goto error;
@ -6803,7 +6803,7 @@ do_assert(cpp_reader * pfile, struct directive *keyword, unsigned char *buf,
(struct tokenlist_list *)xmalloc(sizeof(struct tokenlist_list));
hp = assertion_lookup(pfile, symname, sym_length, hashcode);
if (hp == NULL)
if (!hp)
{
if (sym_length == 7 && !strncmp(symname, "defined", sym_length))
cpp_error(pfile, "`defined' redefined as assertion");
@ -6856,7 +6856,7 @@ do_unassert(cpp_reader * pfile, struct directive *keyword, unsigned char *buf,
tokens = read_token_list(pfile, &error_flag);
if (error_flag)
goto error;
if (tokens == NULL)
if (!tokens)
{
cpp_error(pfile, "empty token list in `#unassert'");
goto error;
@ -6877,7 +6877,7 @@ do_unassert(cpp_reader * pfile, struct directive *keyword, unsigned char *buf,
struct tokenlist_list *tail, *prev;
hp = assertion_lookup(pfile, symname, sym_length, hashcode);
if (hp == NULL)
if (!hp)
return 1;
/* If no token list was specified, then eliminate this assertion
@ -6936,7 +6936,7 @@ check_assertion(cpp_reader * pfile, const char *name, int sym_length,
cpp_pedwarn(pfile, "ANSI C does not allow testing assertions");
hp = assertion_lookup(pfile, name, sym_length, hashcode);
if (hp == NULL)
if (!hp)
/* It is not an assertion; just return false. */
return 0;
@ -7170,7 +7170,7 @@ parse_clear_mark(struct parse_marker *pmark)
for (;; pp = &(*pp)->next)
{
if (*pp == NULL)
if (!*pp)
cpp_fatal("internal error", "in parse_set_mark");
if (*pp == pmark)
break;
@ -7238,7 +7238,7 @@ cpp_print_file_and_line(cpp_reader * pfile)
{
cpp_buffer *ip = cpp_file_buffer(pfile);
if (ip != NULL)
if (ip)
{
long line, col;
@ -7320,7 +7320,7 @@ cpp_error_with_line(cpp_reader * pfile, int line, int column, const char *msg)
cpp_print_containing_files(pfile);
if (ip != NULL)
if (ip)
cpp_file_line_for_message(pfile, ip->nominal_fname, line, column);
cpp_message(pfile, 1, msg, NULL, NULL, NULL);
@ -7341,7 +7341,7 @@ cpp_warning_with_line(cpp_reader * pfile, int line, int column, const char *msg)
ip = cpp_file_buffer(pfile);
if (ip != NULL)
if (ip)
cpp_file_line_for_message(pfile, ip->nominal_fname, line, column);
cpp_message(pfile, 0, msg, NULL, NULL, NULL);
@ -7368,7 +7368,7 @@ cpp_pedwarn_with_file_and_line(cpp_reader * pfile,
if (!CPP_OPTIONS(pfile)->pedantic_errors
&& CPP_OPTIONS(pfile)->inhibit_warnings)
return;
if (file != NULL)
if (file)
cpp_file_line_for_message(pfile, file, line, -1);
cpp_message(pfile, CPP_OPTIONS(pfile)->pedantic_errors,
msg, arg1, arg2, arg3);
@ -7423,7 +7423,7 @@ cpp_error_from_errno(cpp_reader * pfile, const char *name)
cpp_print_containing_files(pfile);
if (ip != NULL)
if (ip)
cpp_file_line_for_message(pfile, ip->nominal_fname, ip->lineno, -1);
cpp_message(pfile, 1, "%s: %s", name, my_strerror(errno), NULL);

View File

@ -527,7 +527,7 @@ SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy)
{
for (i = 0; i < num; i++)
{
if (lst[i] == NULL)
if (!lst[i])
continue;
if ((EoGetDesk(ewin) == EoGetDesk(lst[i]) ||
@ -566,7 +566,7 @@ SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy)
{
for (i = 0; i < num; i++)
{
if (lst[i] == NULL)
if (!lst[i])
continue;
if ((EoGetDesk(ewin) == EoGetDesk(lst[i]) ||
@ -603,7 +603,7 @@ SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy)
{
for (i = 0; i < num; i++)
{
if (lst[i] == NULL)
if (!lst[i])
continue;
if ((EoGetDesk(ewin) == EoGetDesk(lst[i]) ||
@ -643,7 +643,7 @@ SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy)
{
for (i = 0; i < num; i++)
{
if (lst[i] == NULL)
if (!lst[i])
continue;
if ((EoGetDesk(ewin) == EoGetDesk(lst[i]) ||

View File

@ -871,7 +871,7 @@ BrackgroundCreateFromImage(const char *bgid, const char *file,
void
BackgroundIncRefcount(Background * bg)
{
if (bg == NULL)
if (!bg)
return;
bg->ref_count++;
}
@ -879,7 +879,7 @@ BackgroundIncRefcount(Background * bg)
void
BackgroundDecRefcount(Background * bg)
{
if (bg == NULL)
if (!bg)
return;
bg->ref_count--;
if (bg->ref_count <= 0)
@ -889,7 +889,7 @@ BackgroundDecRefcount(Background * bg)
void
BackgroundTouch(Background * bg)
{
if (bg == NULL)
if (!bg)
return;
bg->last_viewed = time(NULL);
}
@ -1300,7 +1300,7 @@ BackgroundsCheckDups(void)
bg = (Background *) ecore_list_next(bg_list);
if (!bg)
break;
for (; (bgx = (Background *) ecore_list_next(bg_list)) != NULL;)
for (; (bgx = (Background *)ecore_list_next(bg_list));)
{
if (bgx->ref_count > 0 || bgx->referenced)
continue;
@ -2337,7 +2337,7 @@ BackgroundSet2(const char *name, const char *params)
int xjust, yjust, xperc, yperc;
int txjust, tyjust, txperc, typerc;
if (params == NULL)
if (!params)
return;
bgf[0] = topf[0] = '\0';

View File

@ -549,7 +549,7 @@ EwinBorderSetTo(EWin * ewin, const Border * b)
if (ewin->border == b)
return;
if (b == NULL)
if (!b)
{
b = ewin->border;
ewin->border = NULL;

View File

@ -75,11 +75,11 @@ GetLine(char *s, int size, FILE * f)
const char *si;
size_t nr;
if (buffer == NULL)
if (!buffer)
{
buffer = EMALLOC(char, LINE_BUFFER_SIZE);
if (buffer == NULL)
if (!buffer)
return NULL;
buffer[LINE_BUFFER_SIZE - 1] = '\0';
}
@ -91,7 +91,7 @@ GetLine(char *s, int size, FILE * f)
for (;;)
{
/* Get a line from the input file */
if (si == NULL)
if (!si)
{
nr = fread(buffer, 1, LINE_BUFFER_SIZE - 1, f);
if (nr == 0)
@ -151,7 +151,7 @@ GetLine(char *s, int size, FILE * f)
done:
bufptr = si;
if (si == NULL)
if (!si)
{
/* EOF */
Efree(buffer);

View File

@ -49,7 +49,7 @@ _CoordsShow(EWin * ewin, int mode)
if (!Conf.movres.mode_info)
return;
if (ewin == NULL || !ewin->state.show_coords)
if (!ewin || !ewin->state.show_coords)
return;
tc = TextclassFind("COORDS", 1);

View File

@ -205,7 +205,7 @@ _ecore_list_append_0(Ecore_List * list, Ecore_List_Node * end)
list->last = end;
if (list->first == NULL)
if (!list->first)
{
list->first = end;
list->index = 0;
@ -251,7 +251,7 @@ _ecore_list_prepend_0(Ecore_List * list, Ecore_List_Node * start)
list->first = start;
/* If no last node, then the first node is the last node */
if (list->last == NULL)
if (!list->last)
list->last = list->first;
list->nodes++;
@ -292,7 +292,7 @@ _ecore_list_insert(Ecore_List * list, Ecore_List_Node * new_node)
if (list->current == list->first)
return _ecore_list_prepend_0(list, new_node);
if (list->current == NULL)
if (!list->current)
{
int ret_value;
@ -751,7 +751,7 @@ ecore_list_items_get(Ecore_List * list, int *pnum)
return NULL;
for (i = 0, ecore_list_first_goto(list);
(b = ecore_list_next(list)) != NULL;)
(b = ecore_list_next(list));)
lst[i++] = b;
*pnum = num;

View File

@ -256,7 +256,7 @@ ConfigurationSave(void)
Eprintf("ConfigurationSave\n");
ecf = e16_db_open(ConfigurationGetFile(buf, sizeof(buf)));
if (ecf == NULL)
if (!ecf)
return;
/* Load module configs */

View File

@ -270,7 +270,7 @@ EobjWindowCreate(int type, int x, int y, int w, int h, int su, const char *name)
eo->floating = 1;
EobjSetLayer(eo, 20);
EobjInit(eo, type, EobjGetWin(eo), x, y, w, h, su, name);
if (eo->win == NULL)
if (!eo->win)
{
Efree(eo);
eo = NULL;

View File

@ -186,7 +186,7 @@ doEwinMoveResize(EWin * ewin, Desk * dsk, int x, int y, int w, int h, int flags)
{
if (floating == 0)
{
dsk = (pdesk == NULL) ? EoGetDesk(ewin) : pdesk;
dsk = (!pdesk) ? EoGetDesk(ewin) : pdesk;
floating = 1;
}
else if (floating == 1)

View File

@ -246,7 +246,7 @@ fileext(const char *file)
const char *p;
p = strrchr(file, '.');
if (p != NULL)
if (p)
{
return p + 1;
}

View File

@ -238,7 +238,7 @@ ListWinGroupMembersForEwin(const EWin * ewin, int action, char nogroup,
goto done;
ewins = EwinListGetAll(&num);
if (ewins == NULL) /* Should not be possible */
if (!ewins) /* Should not be possible */
goto done;
/* Loop through window stack, bottom up */
@ -298,7 +298,7 @@ ListWinGroupMembersForEwin(const EWin * ewin, int action, char nogroup,
}
done:
if (gwins == NULL)
if (!gwins)
{
gwins = EMALLOC(EWin *, 1);
gwins[0] = (EWin *) ewin;

View File

@ -310,7 +310,7 @@ doFocusToEwin(EWin * ewin, int why)
case FOCUS_CLICK:
if (ewin && ewin == Mode.focuswin)
return;
if (ewin == NULL) /* Unfocus */
if (!ewin) /* Unfocus */
break;
if (!FocusEwinValid(ewin, 1, why == FOCUS_CLICK, 0))
return;

View File

@ -98,7 +98,7 @@ TransparencyMakeColorModifier(void)
alpha[i] = 255 - Conf.trans.alpha;
}
if (icm == NULL)
if (!icm)
icm = EImageColorModifierCreate();
EImageColorModifierSetTables(icm, gray, gray, gray, alpha);
}
@ -693,7 +693,7 @@ ImageclassGetImage(ImageClass * ic, int active, int sticky, int state)
if (!is)
return NULL;
if (is->im == NULL)
if (!is->im)
ImagestateRealize(is);
im = is->im;
@ -805,7 +805,7 @@ ImageclassGetImageBlended(ImageClass * ic, Win win, int w, int h, int active,
if (!is)
return NULL;
if (is->im == NULL)
if (!is->im)
ImagestateRealize(is);
im = is->im;
if (!im)
@ -1097,7 +1097,7 @@ ITApply(Win win, ImageClass * ic, ImageState * is,
{
int w, h;
if (win == NULL || !ic)
if (!win || !ic)
return;
w = WinGetW(win);
@ -1116,7 +1116,7 @@ ITApply(Win win, ImageClass * ic, ImageState * is,
ts = TextclassGetTextState(tc, state, active, sticky);
}
if (is->im == NULL)
if (!is->im)
ImagestateRealize(is);
/* Imlib2 will not render pixmaps with dimensions > 8192 */
@ -1240,7 +1240,7 @@ ImageclassApplyCopy(ImageClass * ic, Win win, int w, int h,
{
ImageState *is;
if (pmm == NULL)
if (!pmm)
return;
pmm->type = 0;
@ -1253,7 +1253,7 @@ ImageclassApplyCopy(ImageClass * ic, Win win, int w, int h,
if (!is)
return;
if (is->im == NULL)
if (!is->im)
ImagestateRealize(is);
/* Imlib2 will not render pixmaps with dimensions > 8192 */

View File

@ -379,7 +379,7 @@ SelectIconboxForEwin(EWin * ewin)
for (i = 0; i < num; i++)
{
ct = lst[i];
if (ct->ewin == NULL || ct->type != IB_TYPE_ICONBOX)
if (!ct->ewin || ct->type != IB_TYPE_ICONBOX)
continue;
dx = (EoGetX(ct->ewin) + (EoGetW(ct->ewin) / 2)) -

View File

@ -101,7 +101,7 @@ SetEwinBoolean(const char *txt, char *item, const char *value, int set)
vnew = vold = *item != 0; /* Remember old value */
if (value == NULL || value[0] == '\0')
if (!value || value[0] == '\0')
vnew = !vold;
else if (!strcmp(value, "on"))
vnew = 1;
@ -1224,7 +1224,7 @@ IPC_Reparent(const char *params)
char param2[FILEPATH_LEN_MAX];
EWin *ewin, *enew;
if (params == NULL)
if (!params)
return;
sscanf(params, "%100s %100s", param1, param2);
@ -1867,7 +1867,7 @@ IPC_Help(const char *params)
{
ipc = lst[i];
if (strcmp(params, ipc->name) &&
(ipc->nick == NULL || strcmp(params, ipc->nick)))
(!ipc->nick || strcmp(params, ipc->nick)))
continue;
nick = (ipc->nick) ? ipc->nick : "";

View File

@ -112,7 +112,7 @@ EstrLoc2Int(const char *str, int len)
char *
EstrUtf82Int(const char *str, int len)
{
if (str == NULL)
if (!str)
return NULL;
#if HAVE_ICONV
@ -133,7 +133,7 @@ EstrInt2Enc(const char *str, int want_utf8)
if (Mode.locale.utf8_int == want_utf8)
return str;
if (str == NULL)
if (!str)
return NULL;
if (want_utf8)

View File

@ -614,7 +614,7 @@ ESavePrefixSetup(void)
Mode.conf.prefix = Estrdup(buf);
for (s = Mode.conf.prefix; (s = strchr(s, ':')) != NULL; *s = '-')
for (s = Mode.conf.prefix; (s = strchr(s, ':')); *s = '-')
;
}

View File

@ -1205,7 +1205,7 @@ MenuFindNextItem(Menu * m, MenuItem * mi, int inc)
{
int i;
if (mi == NULL)
if (!mi)
{
if (m->num > 0)
return m->items[0];
@ -1284,13 +1284,13 @@ MenuEventKeyPress(Menu * m, XEvent * ev)
goto check_activate;
case XK_Right:
if (mi == NULL)
if (!mi)
goto check_next;
m = mi->child;
if (!m || m->num <= 0)
break;
ewin = m->ewin;
if (ewin == NULL || !EwinIsMapped(ewin))
if (!ewin || !EwinIsMapped(ewin))
break;
mi = MenuFindItemByChild(m, m->child);
goto check_activate;

View File

@ -1502,7 +1502,7 @@ SnapshotEwinUnmatch(EWin * ewin)
Snapshot *sn;
sn = ewin->snap;
if (sn == NULL)
if (!sn)
return;
ewin->snap = NULL;

View File

@ -289,7 +289,7 @@ fmtstr(char *value, int ljust, int len, int zpad, int precision)
int padlen, strlen, i, c; /* amount to pad */
zpad = 0;
if (value == NULL)
if (!value)
{
value = "<NULL>";
}
@ -457,7 +457,7 @@ dostr(char *str)
static void
dopr_outch(int c)
{
if (end == NULL || output < end)
if (!end || output < end)
{
*output++ = c;
}

View File

@ -168,7 +168,7 @@ doStartupWindowsOpen(void *data __UNUSED__)
void
StartupWindowsOpen(void)
{
if (init_win1 == NULL || init_win2 == NULL)
if (!init_win1 || !init_win2)
return;
Mode.place.enable_features--;

View File

@ -119,7 +119,7 @@ SystrayObjManage(Container * ct, Window xwin)
Eprintf("SystrayObjManage %#lx\n", xwin);
#endif
win = ERegisterWindow(xwin, NULL);
if (win == NULL)
if (!win)
return win;
ESelectInput(win, StructureNotifyMask | PropertyChangeMask);
@ -184,7 +184,7 @@ SystrayObjAdd(Container * ct, Window xwin)
goto bail_out;
win = SystrayObjManage(ct, xwin);
if (win == NULL)
if (!win)
goto bail_out;
swin->win = win;

View File

@ -53,7 +53,7 @@ ThemeCheckPath(const char *path)
int i;
char s[4096];
for (i = 0; (tf = theme_files[i]) != NULL; i++)
for (i = 0; (tf = theme_files[i]); i++)
{
Esnprintf(s, sizeof(s), "%s/%s", path, tf);
if (!isfile(s))
@ -171,7 +171,7 @@ ThemeGetPath(const char *path, char *buf, unsigned int len)
/* We only attempt to dereference a DEFAULT link */
s = strstr(path, "/DEFAULT");
if (s == NULL)
if (!s)
return path;
l = readlink(path, s1, sizeof(s1) - 1);

View File

@ -92,7 +92,7 @@ TooltipCreate(const char *name, const char *ic0, const char *ic1,
ToolTip *tt;
ImageClass *ic;
if (ic0 == NULL || tclass == NULL)
if (!ic0 || !tclass)
return NULL;
ic = ImageclassAlloc(ic0, 0);