Make use of the NULL macro

Use this constant everywhere when referring to a null pointer instead of
casting 0 to various types of pointers. Created using following semantic
patch:

    @@
    type type;
    @@

    - (type *)0
    + NULL

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2011-11-02 18:59:40 +01:00
parent 7cc6305588
commit ce3f0ce76f
8 changed files with 39 additions and 39 deletions

View File

@ -906,10 +906,10 @@ parse_args (int argc, char **argv, struct conf *conf)
else if (gflag) else if (gflag)
{ {
io_init (cfile, datadir); io_init (cfile, datadir);
io_check_dir (path_dir, (int *)0); io_check_dir (path_dir, NULL);
io_check_dir (path_notes, (int *)0); io_check_dir (path_notes, NULL);
io_check_file (path_apts, (int *)0); io_check_file (path_apts, NULL);
io_check_file (path_todo, (int *)0); io_check_file (path_todo, NULL);
io_load_app (); io_load_app ();
io_load_todo (); io_load_todo ();
note_gc (); note_gc ();
@ -920,13 +920,13 @@ parse_args (int argc, char **argv, struct conf *conf)
if (load_data) if (load_data)
{ {
io_init (cfile, datadir); io_init (cfile, datadir);
io_check_dir (path_dir, (int *)0); io_check_dir (path_dir, NULL);
io_check_dir (path_notes, (int *)0); io_check_dir (path_notes, NULL);
} }
if (iflag) if (iflag)
{ {
io_check_file (path_apts, (int *)0); io_check_file (path_apts, NULL);
io_check_file (path_todo, (int *)0); io_check_file (path_todo, NULL);
/* Get default pager in case we need to show a log file. */ /* Get default pager in case we need to show a log file. */
vars_init (conf); vars_init (conf);
io_load_app (); io_load_app ();
@ -938,8 +938,8 @@ parse_args (int argc, char **argv, struct conf *conf)
} }
if (xflag) if (xflag)
{ {
io_check_file (path_apts, (int *)0); io_check_file (path_apts, NULL);
io_check_file (path_todo, (int *)0); io_check_file (path_todo, NULL);
io_load_app (); io_load_app ();
io_load_todo (); io_load_todo ();
io_export_data (xfmt, conf); io_export_data (xfmt, conf);
@ -948,22 +948,22 @@ parse_args (int argc, char **argv, struct conf *conf)
} }
if (tflag) if (tflag)
{ {
io_check_file (path_todo, (int *)0); io_check_file (path_todo, NULL);
io_load_todo (); io_load_todo ();
todo_arg (tnum, Nflag, preg); todo_arg (tnum, Nflag, preg);
non_interactive = 1; non_interactive = 1;
} }
if (nflag) if (nflag)
{ {
io_check_file (path_apts, (int *)0); io_check_file (path_apts, NULL);
io_load_app (); io_load_app ();
next_arg (); next_arg ();
non_interactive = 1; non_interactive = 1;
} }
if (dflag || rflag || sflag) if (dflag || rflag || sflag)
{ {
io_check_file (path_apts, (int *)0); io_check_file (path_apts, NULL);
io_check_file (path_conf, (int *)0); io_check_file (path_conf, NULL);
io_load_app (); io_load_app ();
custom_load_conf (conf); /* To get output date format. */ custom_load_conf (conf); /* To get output date format. */
if (dflag) if (dflag)
@ -977,8 +977,8 @@ parse_args (int argc, char **argv, struct conf *conf)
{ {
struct date day; struct date day;
io_check_file (path_apts, (int *)0); io_check_file (path_apts, NULL);
io_check_file (path_conf, (int *)0); io_check_file (path_conf, NULL);
vars_init (conf); vars_init (conf);
custom_load_conf (conf); /* To get output date format. */ custom_load_conf (conf); /* To get output date format. */
io_load_app (); io_load_app ();

View File

@ -130,7 +130,7 @@ calendar_date_thread (void *arg)
calendar_update_panel (&win[CAL]); calendar_update_panel (&win[CAL]);
} }
return (void *)0; return NULL;
} }
/* Launch the calendar date thread. */ /* Launch the calendar date thread. */

View File

@ -572,7 +572,7 @@ custom_layout_config (void)
" 'a' -> appointment panel\n\n" " 'a' -> appointment panel\n\n"
" 't' -> todo panel\n\n"); " 't' -> todo panel\n\n");
conf_win.p = (WINDOW *)0; conf_win.p = NULL;
strncpy (label, _("layout configuration"), BUFSIZ); strncpy (label, _("layout configuration"), BUFSIZ);
custom_confwin_init (&conf_win, label); custom_confwin_init (&conf_win, label);
cursor = mark = wins_layout () - 1; cursor = mark = wins_layout () - 1;

View File

@ -407,7 +407,7 @@ keys_action_nkey (enum key action, int keynum)
return key->str; return key->str;
i++; i++;
} }
return (char *)0; return NULL;
} }
char * char *
@ -440,7 +440,7 @@ keys_format_label (char *key, int keylen)
int i; int i;
if (keylen > BUFSIZ) if (keylen > BUFSIZ)
return (char *)0; return NULL;
bzero (fmtkey, sizeof (fmtkey)); bzero (fmtkey, sizeof (fmtkey));
if (len == 0) if (len == 0)

View File

@ -176,7 +176,7 @@ dbg_malloc (size_t size, const char *pos)
unsigned *buf; unsigned *buf;
if (size == 0) if (size == 0)
return (void *)0; return NULL;
size = EXTRA_SPACE + (size + sizeof (unsigned) - 1) / sizeof (unsigned); size = EXTRA_SPACE + (size + sizeof (unsigned) - 1) / sizeof (unsigned);
buf = xmalloc (size * sizeof (unsigned)); buf = xmalloc (size * sizeof (unsigned));
@ -197,13 +197,13 @@ dbg_calloc (size_t nmemb, size_t size, const char *pos)
void *buf; void *buf;
if (!nmemb || !size) if (!nmemb || !size)
return (void *)0; return NULL;
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)) == NULL) if ((buf = dbg_malloc (size, pos)) == NULL)
return (void *)0; return NULL;
bzero (buf, size); bzero (buf, size);
@ -216,16 +216,16 @@ 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 == NULL) if (ptr == NULL)
return (void *)0; return NULL;
new_size = nmemb *size; new_size = nmemb *size;
if (new_size == 0) if (new_size == 0)
return (void *)0; return NULL;
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)) == NULL) if ((buf = dbg_malloc (new_size, pos)) == NULL)
return (void *)0; return NULL;
old_size = *((unsigned *)ptr - EXTRA_SPACE_START + BLK_SIZE); old_size = *((unsigned *)ptr - EXTRA_SPACE_START + BLK_SIZE);
cpy_size = (old_size > new_size) ? new_size : old_size; cpy_size = (old_size > new_size) ? new_size : old_size;
@ -243,11 +243,11 @@ dbg_strdup (const char *s, const char *pos)
char *buf; char *buf;
if (s == NULL) if (s == NULL)
return (char *)0; return NULL;
size = strlen (s); size = strlen (s);
if ((buf = dbg_malloc (size + 1, pos)) == NULL) if ((buf = dbg_malloc (size + 1, pos)) == NULL)
return (char *)0; return NULL;
return strncpy (buf, s, size + 1); return strncpy (buf, s, size + 1);
} }

View File

@ -225,7 +225,7 @@ notify_launch_cmd (void)
else if (pid == 0) else if (pid == 0)
{ {
/* Child: launch user defined command */ /* Child: launch user defined command */
if (execlp (nbar.shell, nbar.shell, "-c", nbar.cmd, (char *)0) < 0) if (execlp (nbar.shell, nbar.shell, "-c", nbar.cmd, NULL) < 0)
{ {
ERROR_MSG (_("error while launching command")); ERROR_MSG (_("error while launching command"));
_exit (1); _exit (1);
@ -360,7 +360,7 @@ notify_main_thread (void *arg)
notify_check_next_app (0); notify_check_next_app (0);
} }
} }
pthread_exit ((void *) 0); pthread_exit (NULL);
} }
/* Fill the given structure with information about next appointment. */ /* Fill the given structure with information about next appointment. */
@ -377,7 +377,7 @@ notify_get_next (struct notify_app *a)
a->time = current_time + DAYINSEC; a->time = current_time + DAYINSEC;
a->got_app = 0; a->got_app = 0;
a->state = 0; a->state = 0;
a->txt = (char *)0; a->txt = NULL;
recur_apoint_check_next (a, current_time, get_today ()); recur_apoint_check_next (a, current_time, get_today ());
apoint_check_next (a, current_time); apoint_check_next (a, current_time);
@ -393,7 +393,7 @@ notify_get_next_bkgd (void)
{ {
struct notify_app a; struct notify_app a;
a.txt = (char *)0; a.txt = NULL;
if (!notify_get_next (&a)) if (!notify_get_next (&a))
return 0; return 0;
@ -422,7 +422,7 @@ notify_app_txt (void)
if (notify_app.got_app) if (notify_app.got_app)
return notify_app.txt; return notify_app.txt;
else else
return (char *)0; return NULL;
} }
/* Look for the next appointment within the next 24 hours. */ /* Look for the next appointment within the next 24 hours. */
@ -434,7 +434,7 @@ notify_thread_app (void *arg)
int force = (arg ? 1 : 0); int force = (arg ? 1 : 0);
if (!notify_get_next (&tmp_app)) if (!notify_get_next (&tmp_app))
pthread_exit ((void *)0); pthread_exit (NULL);
if (!tmp_app.got_app) if (!tmp_app.got_app)
{ {
@ -456,7 +456,7 @@ notify_thread_app (void *arg)
mem_free (tmp_app.txt); mem_free (tmp_app.txt);
notify_update_bar (); notify_update_bar ();
pthread_exit ((void *) 0); pthread_exit (NULL);
} }
/* Launch the thread notify_thread_app to look for next appointment. */ /* Launch the thread notify_thread_app to look for next appointment. */
@ -464,7 +464,7 @@ void
notify_check_next_app (int force) notify_check_next_app (int force)
{ {
pthread_t notify_t_app; pthread_t notify_t_app;
void *arg = (force ? (void *)1 : (void *)0); void *arg = (force ? (void *)1 : NULL);
pthread_create (&notify_t_app, &detached_thread_attr, notify_thread_app, pthread_create (&notify_t_app, &detached_thread_attr, notify_thread_app,
arg); arg);

View File

@ -83,7 +83,7 @@ sigs_set_hdlr (int sig, void (*handler)(int))
sigemptyset (&sa.sa_mask); sigemptyset (&sa.sa_mask);
sa.sa_handler = handler; sa.sa_handler = handler;
sa.sa_flags = 0; sa.sa_flags = 0;
if (sigaction (sig, &sa, (struct sigaction *)0) == -1) if (sigaction (sig, &sa, NULL) == -1)
{ {
ERROR_MSG (_("Error setting signal #%d : %s\n"), ERROR_MSG (_("Error setting signal #%d : %s\n"),
sig, strerror (errno)); sig, strerror (errno));

View File

@ -419,7 +419,7 @@ item_in_popup (char *saved_a_start, char *saved_a_end, char *msg,
const int padl = winl - 2, padw = winw - margin_left; const int padl = winl - 2, padw = winw - margin_left;
pad = newpad (padl, padw); pad = newpad (padl, padw);
popup_win = popup (winl, winw, 1, 2, pop_title, (char *)0, 1); popup_win = popup (winl, winw, 1, 2, pop_title, NULL, 1);
if (strncmp (pop_title, _("Appointment"), 11) == 0) if (strncmp (pop_title, _("Appointment"), 11) == 0)
{ {
mvwprintw (popup_win, margin_top, margin_left, "- %s -> %s", mvwprintw (popup_win, margin_top, margin_left, "- %s -> %s",
@ -557,7 +557,7 @@ new_tempfile (const char *prefix, int trailing_len)
close (fd); close (fd);
} }
ERROR_MSG (_("temporary file \"%s\" could not be created"), fullname); ERROR_MSG (_("temporary file \"%s\" could not be created"), fullname);
return (char *)0; return NULL;
} }
fclose (file); fclose (file);