Compare pointers to "NULL" instead of "0".

"bad_zero.cocci" spatch from http://coccinelle.lip6.fr/impact_linux.php.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2011-04-05 01:50:23 +02:00
parent c4c7c8af5d
commit 6fb0f6f4c6
12 changed files with 93 additions and 93 deletions

View File

@ -141,7 +141,7 @@ apoint_new (char *mesg, char *note, long start, long dur, char state)
i = &alist_p->root; i = &alist_p->root;
for (;;) for (;;)
{ {
if (*i == 0 || (*i)->start > start) if (*i == NULL || (*i)->start > start)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
@ -509,7 +509,7 @@ apoint_delete_bynum (long start, unsigned num, enum eraseflg flag)
n = 0; n = 0;
pthread_mutex_lock (&(alist_p->mutex)); pthread_mutex_lock (&(alist_p->mutex));
iptr = &alist_p->root; iptr = &alist_p->root;
for (i = alist_p->root; i != 0; i = i->next) for (i = alist_p->root; i != NULL; i = i->next)
{ {
if (apoint_inday (i, start)) if (apoint_inday (i, start))
{ {
@ -616,7 +616,7 @@ apoint_check_next (struct notify_app *app, long start)
struct apoint *i; struct apoint *i;
pthread_mutex_lock (&(alist_p->mutex)); pthread_mutex_lock (&(alist_p->mutex));
for (i = alist_p->root; i != 0; i = i->next) for (i = alist_p->root; i != NULL; i = i->next)
{ {
if (i->start > app->time) if (i->start > app->time)
{ {
@ -684,7 +684,7 @@ apoint_switch_notify (void)
need_chk_notify = 0; need_chk_notify = 0;
pthread_mutex_lock (&(alist_p->mutex)); pthread_mutex_lock (&(alist_p->mutex));
for (apoint = alist_p->root; apoint != 0; apoint = apoint->next) for (apoint = alist_p->root; apoint != NULL; apoint = apoint->next)
{ {
if (apoint_inday (apoint, date)) if (apoint_inday (apoint, date))
{ {

View File

@ -267,7 +267,7 @@ todo_arg (int priority, int print_note, regex_t *regex)
print_notefile (stdout, i->note, 1); \ print_notefile (stdout, i->note, 1); \
} while (0) } while (0)
for (i = todolist; i != 0; i = i->next) for (i = todolist; i != NULL; i = i->next)
{ {
if (regex && regexec (regex, i->mesg, 0, 0, 0) != 0) if (regex && regexec (regex, i->mesg, 0, 0, 0) != 0)
continue; continue;
@ -370,7 +370,7 @@ app_arg (int add_line, struct date *day, long date, int print_note,
* that date and it is the first one, and then print all the events for * that date and it is the first one, and then print all the events for
* that date. * that date.
*/ */
for (re = recur_elist; re != 0; re = re->next) for (re = recur_elist; re != NULL; re = re->next)
{ {
if (recur_item_inday (re->day, re->exc, re->rpt->type, re->rpt->freq, if (recur_item_inday (re->day, re->exc, re->rpt->type, re->rpt->freq,
re->rpt->until, today)) re->rpt->until, today))
@ -397,7 +397,7 @@ app_arg (int add_line, struct date *day, long date, int print_note,
} }
} }
for (j = eventlist; j != 0; j = j->next) for (j = eventlist; j != NULL; j = j->next)
{ {
if (event_inday (j, today)) if (event_inday (j, today))
{ {
@ -425,7 +425,7 @@ app_arg (int add_line, struct date *day, long date, int print_note,
/* Same process is performed but this time on the appointments. */ /* Same process is performed but this time on the appointments. */
pthread_mutex_lock (&(recur_alist_p->mutex)); pthread_mutex_lock (&(recur_alist_p->mutex));
for (ra = recur_alist_p->root; ra != 0; ra = ra->next) for (ra = recur_alist_p->root; ra != NULL; ra = ra->next)
{ {
if (recur_item_inday (ra->start, ra->exc, ra->rpt->type, ra->rpt->freq, if (recur_item_inday (ra->start, ra->exc, ra->rpt->type, ra->rpt->freq,
ra->rpt->until, today)) ra->rpt->until, today))
@ -465,7 +465,7 @@ app_arg (int add_line, struct date *day, long date, int print_note,
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
pthread_mutex_lock (&(alist_p->mutex)); pthread_mutex_lock (&(alist_p->mutex));
for (i = alist_p->root; i != 0; i = i->next) for (i = alist_p->root; i != NULL; i = i->next)
{ {
if (apoint_inday (i, today)) if (apoint_inday (i, today))
{ {

View File

@ -1243,7 +1243,7 @@ print_keys_bindings (WINDOW *win, int selected_row, int selected_elm, int yoff)
int pos; int pos;
pos = KEYPOS; pos = KEYPOS;
while ((key = keys_action_nkey (action, noelm)) != 0) while ((key = keys_action_nkey (action, noelm)) != NULL)
{ {
if (noelm == selected_elm) if (noelm == selected_elm)
print_key_incolor (win, key, y, pos); print_key_incolor (win, key, y, pos);

View File

@ -90,7 +90,7 @@ day_add_event (int type, char *mesg, char *note, long day, int id)
i = &day_items_ptr; i = &day_items_ptr;
for (;;) for (;;)
{ {
if (*i == 0) if (*i == NULL)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
@ -121,7 +121,7 @@ day_add_apoint (int type, char *mesg, char *note, long start, long dur,
i = &day_items_ptr; i = &day_items_ptr;
for (;;) for (;;)
{ {
if (*i == 0) if (*i == NULL)
{ {
insert_item = 1; insert_item = 1;
} }
@ -153,7 +153,7 @@ day_store_events (long date)
struct event *j; struct event *j;
int e_nb = 0; int e_nb = 0;
for (j = eventlist; j != 0; j = j->next) for (j = eventlist; j != NULL; j = j->next)
{ {
if (event_inday (j, date)) if (event_inday (j, date))
{ {
@ -178,7 +178,7 @@ day_store_recur_events (long date)
struct recur_event *j; struct recur_event *j;
int e_nb = 0; int e_nb = 0;
for (j = recur_elist; j != 0; j = j->next) for (j = recur_elist; j != NULL; j = j->next)
{ {
if (recur_item_inday (j->day, j->exc, j->rpt->type, j->rpt->freq, if (recur_item_inday (j->day, j->exc, j->rpt->type, j->rpt->freq,
j->rpt->until, date)) j->rpt->until, date))
@ -205,7 +205,7 @@ day_store_apoints (long date)
int a_nb = 0; int a_nb = 0;
pthread_mutex_lock (&(alist_p->mutex)); pthread_mutex_lock (&(alist_p->mutex));
for (j = alist_p->root; j != 0; j = j->next) for (j = alist_p->root; j != NULL; j = j->next)
{ {
if (apoint_inday (j, date)) if (apoint_inday (j, date))
{ {
@ -234,7 +234,7 @@ day_store_recur_apoints (long date)
int a_nb = 0, n = 0; int a_nb = 0, n = 0;
pthread_mutex_lock (&(recur_alist_p->mutex)); pthread_mutex_lock (&(recur_alist_p->mutex));
for (j = recur_alist_p->root; j != 0; j = j->next) for (j = recur_alist_p->root; j != NULL; j = j->next)
{ {
if ((real_start = recur_item_inday (j->start, j->exc, if ((real_start = recur_item_inday (j->start, j->exc,
j->rpt->type, j->rpt->freq, j->rpt->type, j->rpt->freq,
@ -266,7 +266,7 @@ day_store_items (long date, unsigned *pnb_events, unsigned *pnb_apoints)
int nb_events, nb_recur_events; int nb_events, nb_recur_events;
int nb_apoints, nb_recur_apoints; int nb_apoints, nb_recur_apoints;
if (day_items_ptr != 0) if (day_items_ptr != NULL)
day_free_list (); day_free_list ();
nb_recur_events = day_store_recur_events (date); nb_recur_events = day_store_recur_events (date);
nb_events = day_store_events (date); nb_events = day_store_events (date);
@ -405,7 +405,7 @@ day_write_pad (long date, int width, int length, int incolor)
line = item_number = 0; line = item_number = 0;
for (p = day_items_ptr; p != 0; p = p->next) for (p = day_items_ptr; p != NULL; p = p->next)
{ {
if (p->type == RECUR_EVNT || p->type == RECUR_APPT) if (p->type == RECUR_EVNT || p->type == RECUR_APPT)
recur = 1; recur = 1;
@ -481,13 +481,13 @@ day_check_if_item (struct date day)
struct apoint *a; struct apoint *a;
const long date = date2sec (day, 0, 0); const long date = date2sec (day, 0, 0);
for (re = recur_elist; re != 0; re = re->next) for (re = recur_elist; re != NULL; re = re->next)
if (recur_item_inday (re->day, re->exc, re->rpt->type, if (recur_item_inday (re->day, re->exc, re->rpt->type,
re->rpt->freq, re->rpt->until, date)) re->rpt->freq, re->rpt->until, date))
return (1); return (1);
pthread_mutex_lock (&(recur_alist_p->mutex)); pthread_mutex_lock (&(recur_alist_p->mutex));
for (ra = recur_alist_p->root; ra != 0; ra = ra->next) for (ra = recur_alist_p->root; ra != NULL; ra = ra->next)
if (recur_item_inday (ra->start, ra->exc, ra->rpt->type, if (recur_item_inday (ra->start, ra->exc, ra->rpt->type,
ra->rpt->freq, ra->rpt->until, date)) ra->rpt->freq, ra->rpt->until, date))
{ {
@ -496,12 +496,12 @@ day_check_if_item (struct date day)
} }
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
for (e = eventlist; e != 0; e = e->next) for (e = eventlist; e != NULL; e = e->next)
if (event_inday (e, date)) if (event_inday (e, date))
return (1); return (1);
pthread_mutex_lock (&(alist_p->mutex)); pthread_mutex_lock (&(alist_p->mutex));
for (a = alist_p->root; a != 0; a = a->next) for (a = alist_p->root; a != NULL; a = a->next)
if (apoint_inday (a, date)) if (apoint_inday (a, date))
{ {
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
@ -547,7 +547,7 @@ day_chk_busy_slices (struct date day, int slicesno, int *slices)
#define SLICENUM(tsec) ((tsec) / slicelen % slicesno) #define SLICENUM(tsec) ((tsec) / slicelen % slicesno)
pthread_mutex_lock (&(recur_alist_p->mutex)); pthread_mutex_lock (&(recur_alist_p->mutex));
for (ra = recur_alist_p->root; ra != 0; ra = ra->next) for (ra = recur_alist_p->root; ra != NULL; ra = ra->next)
if (recur_item_inday (ra->start, ra->exc, ra->rpt->type, if (recur_item_inday (ra->start, ra->exc, ra->rpt->type,
ra->rpt->freq, ra->rpt->until, date)) ra->rpt->freq, ra->rpt->until, date))
{ {
@ -564,7 +564,7 @@ day_chk_busy_slices (struct date day, int slicesno, int *slices)
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
pthread_mutex_lock (&(alist_p->mutex)); pthread_mutex_lock (&(alist_p->mutex));
for (a = alist_p->root; a != 0; a = a->next) for (a = alist_p->root; a != NULL; a = a->next)
if (apoint_inday (a, date)) if (apoint_inday (a, date))
{ {
long start, end; long start, end;

View File

@ -96,7 +96,7 @@ event_new (char *mesg, char *note, long day, int id)
i = &eventlist; i = &eventlist;
for (;;) for (;;)
{ {
if (*i == 0 || (*i)->day > day) if (*i == NULL || (*i)->day > day)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
@ -195,7 +195,7 @@ event_delete_bynum (long start, unsigned num, enum eraseflg flag)
n = 0; n = 0;
iptr = &eventlist; iptr = &eventlist;
for (i = eventlist; i != 0; i = i->next) for (i = eventlist; i != NULL; i = i->next)
{ {
if (event_inday (i, start)) if (event_inday (i, start))
{ {

View File

@ -346,7 +346,7 @@ ical_export_recur_events (FILE *stream)
struct days *day; struct days *day;
char ical_date[BUFSIZ]; char ical_date[BUFSIZ];
for (i = recur_elist; i != 0; i = i->next) for (i = recur_elist; i != NULL; i = i->next)
{ {
date_sec2date_fmt (i->day, ICALDATEFMT, ical_date); date_sec2date_fmt (i->day, ICALDATEFMT, ical_date);
(void)fprintf (stream, "BEGIN:VEVENT\n"); (void)fprintf (stream, "BEGIN:VEVENT\n");
@ -416,7 +416,7 @@ pcal_export_recur_events (FILE *stream)
(void)fprintf (stream, (void)fprintf (stream,
"# (pcal does not support from..until dates specification\n"); "# (pcal does not support from..until dates specification\n");
for (i = recur_elist; i != 0; i = i->next) for (i = recur_elist; i != NULL; i = i->next)
{ {
if (i->rpt->until == 0 && i->rpt->freq == 1) if (i->rpt->until == 0 && i->rpt->freq == 1)
{ {
@ -464,7 +464,7 @@ ical_export_events (FILE *stream)
struct event *i; struct event *i;
char ical_date[BUFSIZ]; char ical_date[BUFSIZ];
for (i = eventlist; i != 0; i = i->next) for (i = eventlist; i != NULL; i = i->next)
{ {
date_sec2date_fmt (i->day, ICALDATEFMT, ical_date); date_sec2date_fmt (i->day, ICALDATEFMT, ical_date);
(void)fprintf (stream, "BEGIN:VEVENT\n"); (void)fprintf (stream, "BEGIN:VEVENT\n");
@ -480,7 +480,7 @@ pcal_export_events (FILE *stream)
struct event *i; struct event *i;
(void)fprintf (stream, "\n# ======\n# Events\n# ======\n"); (void)fprintf (stream, "\n# ======\n# Events\n# ======\n");
for (i = eventlist; i != 0; i = i->next) for (i = eventlist; i != NULL; i = i->next)
pcal_dump_event (stream, i->day, 0, i->mesg); pcal_dump_event (stream, i->day, 0, i->mesg);
(void)fprintf (stream, "\n"); (void)fprintf (stream, "\n");
} }
@ -495,7 +495,7 @@ ical_export_recur_apoints (FILE *stream)
char ical_date[BUFSIZ]; char ical_date[BUFSIZ];
pthread_mutex_lock (&(recur_alist_p->mutex)); pthread_mutex_lock (&(recur_alist_p->mutex));
for (i = recur_alist_p->root; i != 0; i = i->next) for (i = recur_alist_p->root; i != NULL; i = i->next)
{ {
date_sec2date_fmt (i->start, ICALDATETIMEFMT, ical_datetime); date_sec2date_fmt (i->start, ICALDATETIMEFMT, ical_datetime);
(void)fprintf (stream, "BEGIN:VEVENT\n"); (void)fprintf (stream, "BEGIN:VEVENT\n");
@ -544,7 +544,7 @@ pcal_export_recur_apoints (FILE *stream)
(void)fprintf (stream, (void)fprintf (stream,
"# (pcal does not support from..until dates specification\n"); "# (pcal does not support from..until dates specification\n");
for (i = recur_alist_p->root; i != 0; i = i->next) for (i = recur_alist_p->root; i != NULL; i = i->next)
{ {
if (i->rpt->until == 0 && i->rpt->freq == 1) if (i->rpt->until == 0 && i->rpt->freq == 1)
{ {
@ -598,7 +598,7 @@ ical_export_apoints (FILE *stream)
char ical_datetime[BUFSIZ]; char ical_datetime[BUFSIZ];
pthread_mutex_lock (&(alist_p->mutex)); pthread_mutex_lock (&(alist_p->mutex));
for (i = alist_p->root; i != 0; i = i->next) for (i = alist_p->root; i != NULL; i = i->next)
{ {
date_sec2date_fmt (i->start, ICALDATETIMEFMT, ical_datetime); date_sec2date_fmt (i->start, ICALDATETIMEFMT, ical_datetime);
(void)fprintf (stream, "BEGIN:VEVENT\n"); (void)fprintf (stream, "BEGIN:VEVENT\n");
@ -619,7 +619,7 @@ pcal_export_apoints (FILE *stream)
(void)fprintf (stream, "\n# ============\n# Appointments\n# ============\n"); (void)fprintf (stream, "\n# ============\n# Appointments\n# ============\n");
pthread_mutex_lock (&(alist_p->mutex)); pthread_mutex_lock (&(alist_p->mutex));
for (i = alist_p->root; i != 0; i = i->next) for (i = alist_p->root; i != NULL; i = i->next)
pcal_dump_apoint (stream, i->start, i->dur, i->mesg); pcal_dump_apoint (stream, i->start, i->dur, i->mesg);
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
(void)fprintf (stream, "\n"); (void)fprintf (stream, "\n");
@ -631,7 +631,7 @@ ical_export_todo (FILE *stream)
{ {
struct todo *i; struct todo *i;
for (i = todolist; i != 0; i = i->next) for (i = todolist; i != NULL; i = i->next)
{ {
if (i->id < 0) /* completed items */ if (i->id < 0) /* completed items */
continue; continue;
@ -649,7 +649,7 @@ pcal_export_todo (FILE *stream)
struct todo *i; struct todo *i;
(void)fprintf (stream, "#\n# Todos\n#\n"); (void)fprintf (stream, "#\n# Todos\n#\n");
for (i = todolist; i != 0; i = i->next) for (i = todolist; i != NULL; i = i->next)
{ {
if (i->id < 0) /* completed items */ if (i->id < 0) /* completed items */
continue; continue;
@ -831,7 +831,7 @@ io_save_conf (struct conf *conf)
char theme_name[BUFSIZ]; char theme_name[BUFSIZ];
FILE *fp; FILE *fp;
if ((fp = fopen (path_conf, "w")) == 0) if ((fp = fopen (path_conf, "w")) == NULL)
return 0; return 0;
custom_color_theme_name (theme_name); custom_color_theme_name (theme_name);
@ -963,19 +963,19 @@ io_save_apts (void)
struct event *e; struct event *e;
FILE *fp; FILE *fp;
if ((fp = fopen (path_apts, "w")) == 0) if ((fp = fopen (path_apts, "w")) == NULL)
return 0; return 0;
recur_save_data (fp); recur_save_data (fp);
if (ui_mode == UI_CURSES) if (ui_mode == UI_CURSES)
pthread_mutex_lock (&(alist_p->mutex)); pthread_mutex_lock (&(alist_p->mutex));
for (a = alist_p->root; a != 0; a = a->next) for (a = alist_p->root; a != NULL; a = a->next)
apoint_write (a, fp); apoint_write (a, fp);
if (ui_mode == UI_CURSES) if (ui_mode == UI_CURSES)
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
for (e = eventlist; e != 0; e = e->next) for (e = eventlist; e != NULL; e = e->next)
event_write (e, fp); event_write (e, fp);
file_close (fp, __FILE_POS__); file_close (fp, __FILE_POS__);
@ -989,10 +989,10 @@ io_save_todo (void)
struct todo *t; struct todo *t;
FILE *fp; FILE *fp;
if ((fp = fopen (path_todo, "w")) == 0) if ((fp = fopen (path_todo, "w")) == NULL)
return 0; return 0;
for (t = todolist; t != 0; t = t->next) for (t = todolist; t != NULL; t = t->next)
{ {
if (t->note) if (t->note)
(void)fprintf (fp, "[%d]>%s %s\n", t->id, t->note, t->mesg); (void)fprintf (fp, "[%d]>%s %s\n", t->id, t->note, t->mesg);
@ -1010,7 +1010,7 @@ io_save_keys (void)
{ {
FILE *fp; FILE *fp;
if ((fp = fopen (path_keys, "w")) == 0) if ((fp = fopen (path_keys, "w")) == NULL)
return 0; return 0;
keys_save_bindings (fp); keys_save_bindings (fp);
@ -1516,7 +1516,7 @@ io_file_exist (char *file)
if (!file) if (!file)
return 0; return 0;
if ((fd = fopen (file, "r")) == 0) if ((fd = fopen (file, "r")) == NULL)
return 0; return 0;
(void)fclose (fd); (void)fclose (fd);
@ -1624,7 +1624,7 @@ io_export_data (enum export_type type, struct conf *conf)
/* NOTREACHED */ /* NOTREACHED */
} }
if (stream == 0) if (stream == NULL)
return; return;
cb_export_header[type] (stream); cb_export_header[type] (stream);
@ -2774,7 +2774,7 @@ io_import_data (enum import_type type, struct conf *conf, char *stream_name)
"Aborting...")); "Aborting..."));
log = io_log_init (); log = io_log_init ();
if (log == 0) if (log == NULL)
{ {
if (stream != stdin) if (stream != stdin)
file_close (stream, __FILE_POS__); file_close (stream, __FILE_POS__);
@ -2840,15 +2840,15 @@ io_log_init (void)
struct io_file *log; struct io_file *log;
logname = new_tempfile (logprefix, NOTESIZ); logname = new_tempfile (logprefix, NOTESIZ);
RETVAL_IF (logname == 0, 0, RETVAL_IF (logname == NULL, 0,
_("Warning: could not create temporary log file, Aborting...")); _("Warning: could not create temporary log file, Aborting..."));
log = mem_malloc (sizeof (struct io_file)); log = mem_malloc (sizeof (struct io_file));
RETVAL_IF (log == 0, 0, RETVAL_IF (log == NULL, 0,
_("Warning: could not open temporary log file, Aborting...")); _("Warning: could not open temporary log file, Aborting..."));
(void)snprintf (log->name, sizeof (log->name), "%s%s", logprefix, logname); (void)snprintf (log->name, sizeof (log->name), "%s%s", logprefix, logname);
mem_free (logname); mem_free (logname);
log->fd = fopen (log->name, "w"); log->fd = fopen (log->name, "w");
if (log->fd == 0) if (log->fd == NULL)
{ {
ERROR_MSG (_("Warning: could not open temporary log file, Aborting...")); ERROR_MSG (_("Warning: could not open temporary log file, Aborting..."));
mem_free (log); mem_free (log);
@ -2871,7 +2871,7 @@ io_log_display (struct io_file *log, char *msg, char *pager)
char *choices = "[y/n] "; char *choices = "[y/n] ";
int ans; int ans;
RETURN_IF (log == 0, _("No log file to display!")); RETURN_IF (log == NULL, _("No log file to display!"));
if (ui_mode == UI_CMDLINE) if (ui_mode == UI_CMDLINE)
{ {
printf ("\n%s %s", msg, choices); printf ("\n%s %s", msg, choices);
@ -3030,7 +3030,7 @@ io_get_pid (char *file)
if (!file) if (!file)
return 0; return 0;
if ((fp = fopen (file, "r")) == 0) if ((fp = fopen (file, "r")) == NULL)
return 0; return 0;
if (fscanf (fp, "%u", &pid) != 1) if (fscanf (fp, "%u", &pid) != 1)

View File

@ -145,7 +145,7 @@ keys_free (void)
for (key = 0; key < NBKEYS; key++) for (key = 0; key < NBKEYS; key++)
{ {
if (keys[key] == 0) if (keys[key] == NULL)
continue; continue;
i = &keys[key]; i = &keys[key];
@ -607,7 +607,7 @@ keys_check_missing_bindings (void)
for (i = 0; i < NBKEYS; i++) for (i = 0; i < NBKEYS; i++)
{ {
if (keys[i] == 0) if (keys[i] == NULL)
return 1; return 1;
} }
return 0; return 0;
@ -620,7 +620,7 @@ keys_fill_missing (void)
for (i = 0; i < NBKEYS; i++) for (i = 0; i < NBKEYS; i++)
{ {
if (keys[i] == 0) if (keys[i] == NULL)
{ {
char *p, tmpbuf[BUFSIZ]; char *p, tmpbuf[BUFSIZ];

View File

@ -74,7 +74,7 @@ stats_add_blk (size_t size, const char *pos)
struct mem_blk *o, **i; struct mem_blk *o, **i;
o = malloc (sizeof (*o)); o = malloc (sizeof (*o));
EXIT_IF (o == 0, _("could not allocate memory to store block info")); EXIT_IF (o == NULL, _("could not allocate memory to store block info"));
mstats.ncall++; mstats.ncall++;
@ -120,7 +120,7 @@ xmalloc (size_t size)
EXIT_IF (size == 0, _("xmalloc: zero size")); EXIT_IF (size == 0, _("xmalloc: zero size"));
p = malloc (size); p = malloc (size);
EXIT_IF (p == 0, _("xmalloc: out of memory")); EXIT_IF (p == NULL, _("xmalloc: out of memory"));
return p; return p;
} }
@ -133,7 +133,7 @@ xcalloc (size_t nmemb, size_t size)
EXIT_IF (nmemb == 0 || size == 0, _("xcalloc: zero size")); EXIT_IF (nmemb == 0 || size == 0, _("xcalloc: zero size"));
EXIT_IF (SIZE_MAX / nmemb < size, _("xcalloc: overflow")); EXIT_IF (SIZE_MAX / nmemb < size, _("xcalloc: overflow"));
p = calloc (nmemb, size); p = calloc (nmemb, size);
EXIT_IF (p == 0, _("xcalloc: out of memory")); EXIT_IF (p == NULL, _("xcalloc: out of memory"));
return p; return p;
} }
@ -148,7 +148,7 @@ xrealloc (void *ptr, size_t nmemb, size_t size)
EXIT_IF (new_size == 0, _("xrealloc: zero size")); EXIT_IF (new_size == 0, _("xrealloc: zero size"));
EXIT_IF (SIZE_MAX / nmemb < size, _("xrealloc: overflow")); EXIT_IF (SIZE_MAX / nmemb < size, _("xrealloc: overflow"));
new_ptr = realloc (ptr, new_size); new_ptr = realloc (ptr, new_size);
EXIT_IF (new_ptr == 0, _("xrealloc: out of memory")); EXIT_IF (new_ptr == NULL, _("xrealloc: out of memory"));
return new_ptr; return new_ptr;
} }
@ -168,7 +168,7 @@ xstrdup (const char *str)
void void
xfree (void *p) xfree (void *p)
{ {
EXIT_IF (p == 0, _("xfree: null pointer")); EXIT_IF (p == NULL, _("xfree: null pointer"));
free (p); free (p);
} }
@ -204,7 +204,7 @@ dbg_calloc (size_t nmemb, size_t size, const char *pos)
EXIT_IF (nmemb > SIZE_MAX / size, _("overflow at %s"), pos); EXIT_IF (nmemb > SIZE_MAX / size, _("overflow at %s"), pos);
size *= nmemb; size *= nmemb;
if ((buf = dbg_malloc (size, pos)) == 0) if ((buf = dbg_malloc (size, pos)) == NULL)
return (void *)0; return (void *)0;
bzero (buf, size); bzero (buf, size);
@ -217,7 +217,7 @@ dbg_realloc (void *ptr, size_t nmemb, size_t size, const char *pos)
{ {
unsigned *buf, old_size, new_size, cpy_size; unsigned *buf, old_size, new_size, cpy_size;
if (ptr == 0) if (ptr == NULL)
return (void *)0; return (void *)0;
new_size = nmemb *size; new_size = nmemb *size;
@ -226,7 +226,7 @@ dbg_realloc (void *ptr, size_t nmemb, size_t size, const char *pos)
EXIT_IF (nmemb > SIZE_MAX / size, _("overflow at %s"), pos); EXIT_IF (nmemb > SIZE_MAX / size, _("overflow at %s"), pos);
if ((buf = dbg_malloc (new_size, pos)) == 0) if ((buf = dbg_malloc (new_size, pos)) == NULL)
return (void *)0; return (void *)0;
old_size = *((unsigned *)ptr - EXTRA_SPACE_START + BLK_SIZE); old_size = *((unsigned *)ptr - EXTRA_SPACE_START + BLK_SIZE);
@ -244,11 +244,11 @@ dbg_strdup (const char *s, const char *pos)
size_t size; size_t size;
char *buf; char *buf;
if (s == 0) if (s == NULL)
return (char *)0; return (char *)0;
size = strlen (s); size = strlen (s);
if ((buf = dbg_malloc (size + 1, pos)) == 0) if ((buf = dbg_malloc (size + 1, pos)) == NULL)
return (char *)0; return (char *)0;
return strncpy (buf, s, size + 1); return strncpy (buf, s, size + 1);
@ -259,7 +259,7 @@ dbg_free (void *ptr, const char *pos)
{ {
unsigned *buf, size; unsigned *buf, size;
EXIT_IF (ptr == 0, _("dbg_free: null pointer at %s"), pos); EXIT_IF (ptr == NULL, _("dbg_free: null pointer at %s"), pos);
buf = (unsigned *)ptr - EXTRA_SPACE_START; buf = (unsigned *)ptr - EXTRA_SPACE_START;
size = buf[BLK_SIZE]; size = buf[BLK_SIZE];
@ -286,7 +286,7 @@ dbg_free (void *ptr, const char *pos)
static void static void
dump_block_info (struct mem_blk *blk) dump_block_info (struct mem_blk *blk)
{ {
if (blk == 0) if (blk == NULL)
return; return;
printf (_("---==== MEMORY BLOCK ====----------------\n")); printf (_("---==== MEMORY BLOCK ====----------------\n"));

View File

@ -72,7 +72,7 @@ recur_add_exc (struct days **exc, long day)
i = exc; i = exc;
for (;;) for (;;)
{ {
if (*i == 0 || (*i)->st > day) if (*i == NULL || (*i)->st > day)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
@ -243,7 +243,7 @@ recur_apoint_new (char *mesg, char *note, long start, long dur, char state,
o = mem_malloc (sizeof (struct recur_apoint)); o = mem_malloc (sizeof (struct recur_apoint));
o->rpt = mem_malloc (sizeof (struct rpt)); o->rpt = mem_malloc (sizeof (struct rpt));
o->mesg = mem_strdup (mesg); o->mesg = mem_strdup (mesg);
o->note = (note != 0) ? mem_strdup (note) : 0; o->note = (note != NULL) ? mem_strdup (note) : 0;
o->start = start; o->start = start;
o->state = state; o->state = state;
o->dur = dur; o->dur = dur;
@ -262,7 +262,7 @@ recur_apoint_new (char *mesg, char *note, long start, long dur, char state,
i = &recur_alist_p->root; i = &recur_alist_p->root;
for (;;) for (;;)
{ {
if (*i == 0 || (*i)->start > start) if (*i == NULL || (*i)->start > start)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
@ -285,7 +285,7 @@ recur_event_new (char *mesg, char *note, long day, int id, int type, int freq,
o = mem_malloc (sizeof (struct recur_event)); o = mem_malloc (sizeof (struct recur_event));
o->rpt = mem_malloc (sizeof (struct rpt)); o->rpt = mem_malloc (sizeof (struct rpt));
o->mesg = mem_strdup (mesg); o->mesg = mem_strdup (mesg);
o->note = (note != 0) ? mem_strdup (note) : 0; o->note = (note != NULL) ? mem_strdup (note) : 0;
o->day = day; o->day = day;
o->id = id; o->id = id;
o->rpt->type = type; o->rpt->type = type;
@ -302,7 +302,7 @@ recur_event_new (char *mesg, char *note, long day, int id, int type, int freq,
i = &recur_elist; i = &recur_elist;
for (;;) for (;;)
{ {
if (*i == 0 || (*i)->day > day) if (*i == NULL || (*i)->day > day)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
@ -510,7 +510,7 @@ recur_apoint_write (struct recur_apoint *o, FILE *f)
o->rpt->freq, recur_def2char (o->rpt->type), o->rpt->freq, recur_def2char (o->rpt->type),
lt->tm_mon + 1, lt->tm_mday, 1900 + lt->tm_year); lt->tm_mon + 1, lt->tm_mday, 1900 + lt->tm_year);
} }
if (o->exc != 0) if (o->exc != NULL)
recur_write_exc (o->exc, f); recur_write_exc (o->exc, f);
(void)fprintf (f, "} "); (void)fprintf (f, "} ");
if (o->note != NULL) if (o->note != NULL)
@ -554,7 +554,7 @@ recur_event_write (struct recur_event *o, FILE *f)
o->rpt->freq, recur_def2char (o->rpt->type), o->rpt->freq, recur_def2char (o->rpt->type),
end_mon, end_day, end_year); end_mon, end_day, end_year);
} }
if (o->exc != 0) if (o->exc != NULL)
recur_write_exc (o->exc, f); recur_write_exc (o->exc, f);
(void)fprintf (f, "} "); (void)fprintf (f, "} ");
if (o->note != NULL) if (o->note != NULL)
@ -569,11 +569,11 @@ recur_save_data (FILE *f)
struct recur_event *re; struct recur_event *re;
struct recur_apoint *ra; struct recur_apoint *ra;
for (re = recur_elist; re != 0; re = re->next) for (re = recur_elist; re != NULL; re = re->next)
recur_event_write (re, f); recur_event_write (re, f);
pthread_mutex_lock (&(recur_alist_p->mutex)); pthread_mutex_lock (&(recur_alist_p->mutex));
for (ra = recur_alist_p->root; ra != 0; ra = ra->next) for (ra = recur_alist_p->root; ra != NULL; ra = ra->next)
recur_apoint_write (ra, f); recur_apoint_write (ra, f);
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
} }
@ -665,7 +665,7 @@ recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
t = day_start; t = day_start;
lt_day = *localtime (&t); lt_day = *localtime (&t);
for (exc = item_exc; exc != 0; exc = exc->next) for (exc = item_exc; exc != NULL; exc = exc->next)
if (exc->st < day_end && exc->st >= day_start) if (exc->st < day_end && exc->st >= day_start)
return (0); return (0);
@ -740,7 +740,7 @@ recur_event_erase (long start, unsigned num, unsigned delete_whole,
struct recur_event *i, **iptr; struct recur_event *i, **iptr;
iptr = &recur_elist; iptr = &recur_elist;
for (i = recur_elist; i != 0; i = i->next) for (i = recur_elist; i != NULL; i = i->next)
{ {
if (recur_item_inday (i->day, i->exc, i->rpt->type, if (recur_item_inday (i->day, i->exc, i->rpt->type,
i->rpt->freq, i->rpt->until, start)) i->rpt->freq, i->rpt->until, start))
@ -807,7 +807,7 @@ recur_apoint_erase (long start, unsigned num, unsigned delete_whole,
pthread_mutex_lock (&(recur_alist_p->mutex)); pthread_mutex_lock (&(recur_alist_p->mutex));
iptr = &recur_alist_p->root; iptr = &recur_alist_p->root;
for (i = recur_alist_p->root; i != 0; i = i->next) for (i = recur_alist_p->root; i != NULL; i = i->next)
{ {
if (recur_item_inday (i->start, i->exc, i->rpt->type, if (recur_item_inday (i->start, i->exc, i->rpt->type,
i->rpt->freq, i->rpt->until, start)) i->rpt->freq, i->rpt->until, start))
@ -1061,7 +1061,7 @@ recur_apoint_check_next (struct notify_app *app, long start, long day)
long real_recur_start_time; long real_recur_start_time;
pthread_mutex_lock (&(recur_alist_p->mutex)); pthread_mutex_lock (&(recur_alist_p->mutex));
for (i = recur_alist_p->root; i != 0; i = i->next) for (i = recur_alist_p->root; i != NULL; i = i->next)
{ {
if (i->start > app->time) if (i->start > app->time)
{ {
@ -1095,7 +1095,7 @@ recur_get_apoint (long date, int num)
int n = 0; int n = 0;
pthread_mutex_lock (&(recur_alist_p->mutex)); pthread_mutex_lock (&(recur_alist_p->mutex));
for (o = recur_alist_p->root; o != 0; o = o->next) for (o = recur_alist_p->root; o != NULL; o = o->next)
{ {
if (recur_item_inday (o->start, o->exc, o->rpt->type, if (recur_item_inday (o->start, o->exc, o->rpt->type,
o->rpt->freq, o->rpt->until, date)) o->rpt->freq, o->rpt->until, date))
@ -1120,7 +1120,7 @@ recur_get_event (long date, int num)
struct recur_event *o; struct recur_event *o;
int n = 0; int n = 0;
for (o = recur_elist; o != 0; o = o->next) for (o = recur_elist; o != NULL; o = o->next)
{ {
if (recur_item_inday (o->day, o->exc, o->rpt->type, if (recur_item_inday (o->day, o->exc, o->rpt->type,
o->rpt->freq, o->rpt->until, date)) o->rpt->freq, o->rpt->until, date))
@ -1148,7 +1148,7 @@ recur_apoint_switch_notify (long date, int recur_nb)
need_chk_notify = 0; need_chk_notify = 0;
pthread_mutex_lock (&(recur_alist_p->mutex)); pthread_mutex_lock (&(recur_alist_p->mutex));
for (o = recur_alist_p->root; o != 0; o = o->next) for (o = recur_alist_p->root; o != NULL; o = o->next)
{ {
if (recur_item_inday (o->start, o->exc, o->rpt->type, if (recur_item_inday (o->start, o->exc, o->rpt->type,
o->rpt->freq, o->rpt->until, date)) o->rpt->freq, o->rpt->until, date))
@ -1187,7 +1187,7 @@ recur_event_paste_item (void)
{ {
struct days *exc; struct days *exc;
for (exc = bkp_cut_recur_event.exc; exc != 0; exc = exc->next) for (exc = bkp_cut_recur_event.exc; exc != NULL; exc = exc->next)
exc->st += time_shift; exc->st += time_shift;
} }
@ -1217,7 +1217,7 @@ recur_apoint_paste_item (void)
{ {
struct days *exc; struct days *exc;
for (exc = bkp_cut_recur_apoint.exc; exc != 0; exc = exc->next) for (exc = bkp_cut_recur_apoint.exc; exc != NULL; exc = exc->next)
exc->st += time_shift; exc->st += time_shift;
} }

View File

@ -182,7 +182,7 @@ todo_add (char *mesg, int id, char *note)
absid = abs (id); absid = abs (id);
for (;;) for (;;)
{ {
if (*i == 0 || abs ((*i)->id) > absid) if (*i == NULL || abs ((*i)->id) > absid)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
@ -201,7 +201,7 @@ todo_delete_note_bynum (unsigned num)
struct todo *i; struct todo *i;
n = 0; n = 0;
for (i = todolist; i != 0; i = i->next) for (i = todolist; i != NULL; i = i->next)
{ {
if (n == num) if (n == num)
{ {
@ -225,7 +225,7 @@ todo_delete_bynum (unsigned num, enum eraseflg flag)
n = 0; n = 0;
iptr = &todolist; iptr = &todolist;
for (i = todolist; i != 0; i = i->next) for (i = todolist; i != NULL; i = i->next)
{ {
if (n == num) if (n == num)
{ {
@ -451,7 +451,7 @@ todo_update_panel (int which_pan)
/* Print todo item in the panel. */ /* Print todo item in the panel. */
erase_window_part (win[TOD].p, 1, title_lines, win[TOD].w - 2, erase_window_part (win[TOD].p, 1, title_lines, win[TOD].w - 2,
win[TOD].h - 2); win[TOD].h - 2);
for (i = todolist; i != 0; i = i->next) for (i = todolist; i != NULL; i = i->next)
{ {
num_todo++; num_todo++;
t_realpos = num_todo - first; t_realpos = num_todo - first;

View File

@ -110,7 +110,7 @@ fatalbox (const char *errmsg)
const int MSGLEN = WINCOL - 2; const int MSGLEN = WINCOL - 2;
char msg[MSGLEN]; char msg[MSGLEN];
if (errmsg == 0) if (errmsg == NULL)
return; return;
(void)strncpy (msg, errmsg, MSGLEN); (void)strncpy (msg, errmsg, MSGLEN);
@ -137,7 +137,7 @@ warnbox (const char *msg)
const int MSGLEN = WINCOL - 2; const int MSGLEN = WINCOL - 2;
char displmsg[MSGLEN]; char displmsg[MSGLEN];
if (msg == 0) if (msg == NULL)
return; return;
(void)strncpy (displmsg, msg, MSGLEN); (void)strncpy (displmsg, msg, MSGLEN);
@ -405,7 +405,7 @@ updatestring (WINDOW *win, char **str, int x, int y)
{ {
len = strlen (buf); len = strlen (buf);
*str = mem_realloc (*str, len + 1, 1); *str = mem_realloc (*str, len + 1, 1);
EXIT_IF (*str == 0, _("out of memory")); EXIT_IF (*str == NULL, _("out of memory"));
(void)memcpy (*str, buf, len + 1); (void)memcpy (*str, buf, len + 1);
} }

View File

@ -266,7 +266,7 @@ wins_init (void)
void void
wins_scrollwin_init (struct scrollwin *sw) wins_scrollwin_init (struct scrollwin *sw)
{ {
EXIT_IF (sw == 0, "null pointer"); EXIT_IF (sw == NULL, "null pointer");
sw->win.p = newwin (sw->win.h, sw->win.w, sw->win.y, sw->win.x); sw->win.p = newwin (sw->win.h, sw->win.w, sw->win.y, sw->win.x);
sw->pad.p = newpad (sw->pad.h, sw->pad.w); sw->pad.p = newpad (sw->pad.h, sw->pad.w);
sw->first_visible_line = 0; sw->first_visible_line = 0;
@ -277,7 +277,7 @@ wins_scrollwin_init (struct scrollwin *sw)
void void
wins_scrollwin_delete (struct scrollwin *sw) wins_scrollwin_delete (struct scrollwin *sw)
{ {
EXIT_IF (sw == 0, "null pointer"); EXIT_IF (sw == NULL, "null pointer");
delwin(sw->win.p); delwin(sw->win.p);
delwin(sw->pad.p); delwin(sw->pad.p);
} }