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:
parent
7cc6305588
commit
ce3f0ce76f
32
src/args.c
32
src/args.c
@ -906,10 +906,10 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
else if (gflag)
|
||||
{
|
||||
io_init (cfile, datadir);
|
||||
io_check_dir (path_dir, (int *)0);
|
||||
io_check_dir (path_notes, (int *)0);
|
||||
io_check_file (path_apts, (int *)0);
|
||||
io_check_file (path_todo, (int *)0);
|
||||
io_check_dir (path_dir, NULL);
|
||||
io_check_dir (path_notes, NULL);
|
||||
io_check_file (path_apts, NULL);
|
||||
io_check_file (path_todo, NULL);
|
||||
io_load_app ();
|
||||
io_load_todo ();
|
||||
note_gc ();
|
||||
@ -920,13 +920,13 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
if (load_data)
|
||||
{
|
||||
io_init (cfile, datadir);
|
||||
io_check_dir (path_dir, (int *)0);
|
||||
io_check_dir (path_notes, (int *)0);
|
||||
io_check_dir (path_dir, NULL);
|
||||
io_check_dir (path_notes, NULL);
|
||||
}
|
||||
if (iflag)
|
||||
{
|
||||
io_check_file (path_apts, (int *)0);
|
||||
io_check_file (path_todo, (int *)0);
|
||||
io_check_file (path_apts, NULL);
|
||||
io_check_file (path_todo, NULL);
|
||||
/* Get default pager in case we need to show a log file. */
|
||||
vars_init (conf);
|
||||
io_load_app ();
|
||||
@ -938,8 +938,8 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
}
|
||||
if (xflag)
|
||||
{
|
||||
io_check_file (path_apts, (int *)0);
|
||||
io_check_file (path_todo, (int *)0);
|
||||
io_check_file (path_apts, NULL);
|
||||
io_check_file (path_todo, NULL);
|
||||
io_load_app ();
|
||||
io_load_todo ();
|
||||
io_export_data (xfmt, conf);
|
||||
@ -948,22 +948,22 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
}
|
||||
if (tflag)
|
||||
{
|
||||
io_check_file (path_todo, (int *)0);
|
||||
io_check_file (path_todo, NULL);
|
||||
io_load_todo ();
|
||||
todo_arg (tnum, Nflag, preg);
|
||||
non_interactive = 1;
|
||||
}
|
||||
if (nflag)
|
||||
{
|
||||
io_check_file (path_apts, (int *)0);
|
||||
io_check_file (path_apts, NULL);
|
||||
io_load_app ();
|
||||
next_arg ();
|
||||
non_interactive = 1;
|
||||
}
|
||||
if (dflag || rflag || sflag)
|
||||
{
|
||||
io_check_file (path_apts, (int *)0);
|
||||
io_check_file (path_conf, (int *)0);
|
||||
io_check_file (path_apts, NULL);
|
||||
io_check_file (path_conf, NULL);
|
||||
io_load_app ();
|
||||
custom_load_conf (conf); /* To get output date format. */
|
||||
if (dflag)
|
||||
@ -977,8 +977,8 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
{
|
||||
struct date day;
|
||||
|
||||
io_check_file (path_apts, (int *)0);
|
||||
io_check_file (path_conf, (int *)0);
|
||||
io_check_file (path_apts, NULL);
|
||||
io_check_file (path_conf, NULL);
|
||||
vars_init (conf);
|
||||
custom_load_conf (conf); /* To get output date format. */
|
||||
io_load_app ();
|
||||
|
@ -130,7 +130,7 @@ calendar_date_thread (void *arg)
|
||||
calendar_update_panel (&win[CAL]);
|
||||
}
|
||||
|
||||
return (void *)0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Launch the calendar date thread. */
|
||||
|
@ -572,7 +572,7 @@ custom_layout_config (void)
|
||||
" 'a' -> appointment panel\n\n"
|
||||
" 't' -> todo panel\n\n");
|
||||
|
||||
conf_win.p = (WINDOW *)0;
|
||||
conf_win.p = NULL;
|
||||
strncpy (label, _("layout configuration"), BUFSIZ);
|
||||
custom_confwin_init (&conf_win, label);
|
||||
cursor = mark = wins_layout () - 1;
|
||||
|
@ -407,7 +407,7 @@ keys_action_nkey (enum key action, int keynum)
|
||||
return key->str;
|
||||
i++;
|
||||
}
|
||||
return (char *)0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
@ -440,7 +440,7 @@ keys_format_label (char *key, int keylen)
|
||||
int i;
|
||||
|
||||
if (keylen > BUFSIZ)
|
||||
return (char *)0;
|
||||
return NULL;
|
||||
|
||||
bzero (fmtkey, sizeof (fmtkey));
|
||||
if (len == 0)
|
||||
|
16
src/mem.c
16
src/mem.c
@ -176,7 +176,7 @@ dbg_malloc (size_t size, const char *pos)
|
||||
unsigned *buf;
|
||||
|
||||
if (size == 0)
|
||||
return (void *)0;
|
||||
return NULL;
|
||||
|
||||
size = EXTRA_SPACE + (size + sizeof (unsigned) - 1) / sizeof (unsigned);
|
||||
buf = xmalloc (size * sizeof (unsigned));
|
||||
@ -197,13 +197,13 @@ dbg_calloc (size_t nmemb, size_t size, const char *pos)
|
||||
void *buf;
|
||||
|
||||
if (!nmemb || !size)
|
||||
return (void *)0;
|
||||
return NULL;
|
||||
|
||||
EXIT_IF (nmemb > SIZE_MAX / size, _("overflow at %s"), pos);
|
||||
|
||||
size *= nmemb;
|
||||
if ((buf = dbg_malloc (size, pos)) == NULL)
|
||||
return (void *)0;
|
||||
return NULL;
|
||||
|
||||
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;
|
||||
|
||||
if (ptr == NULL)
|
||||
return (void *)0;
|
||||
return NULL;
|
||||
|
||||
new_size = nmemb *size;
|
||||
if (new_size == 0)
|
||||
return (void *)0;
|
||||
return NULL;
|
||||
|
||||
EXIT_IF (nmemb > SIZE_MAX / size, _("overflow at %s"), pos);
|
||||
|
||||
if ((buf = dbg_malloc (new_size, pos)) == NULL)
|
||||
return (void *)0;
|
||||
return NULL;
|
||||
|
||||
old_size = *((unsigned *)ptr - EXTRA_SPACE_START + BLK_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;
|
||||
|
||||
if (s == NULL)
|
||||
return (char *)0;
|
||||
return NULL;
|
||||
|
||||
size = strlen (s);
|
||||
if ((buf = dbg_malloc (size + 1, pos)) == NULL)
|
||||
return (char *)0;
|
||||
return NULL;
|
||||
|
||||
return strncpy (buf, s, size + 1);
|
||||
}
|
||||
|
16
src/notify.c
16
src/notify.c
@ -225,7 +225,7 @@ notify_launch_cmd (void)
|
||||
else if (pid == 0)
|
||||
{
|
||||
/* 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"));
|
||||
_exit (1);
|
||||
@ -360,7 +360,7 @@ notify_main_thread (void *arg)
|
||||
notify_check_next_app (0);
|
||||
}
|
||||
}
|
||||
pthread_exit ((void *) 0);
|
||||
pthread_exit (NULL);
|
||||
}
|
||||
|
||||
/* 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->got_app = 0;
|
||||
a->state = 0;
|
||||
a->txt = (char *)0;
|
||||
a->txt = NULL;
|
||||
recur_apoint_check_next (a, current_time, get_today ());
|
||||
apoint_check_next (a, current_time);
|
||||
|
||||
@ -393,7 +393,7 @@ notify_get_next_bkgd (void)
|
||||
{
|
||||
struct notify_app a;
|
||||
|
||||
a.txt = (char *)0;
|
||||
a.txt = NULL;
|
||||
if (!notify_get_next (&a))
|
||||
return 0;
|
||||
|
||||
@ -422,7 +422,7 @@ notify_app_txt (void)
|
||||
if (notify_app.got_app)
|
||||
return notify_app.txt;
|
||||
else
|
||||
return (char *)0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Look for the next appointment within the next 24 hours. */
|
||||
@ -434,7 +434,7 @@ notify_thread_app (void *arg)
|
||||
int force = (arg ? 1 : 0);
|
||||
|
||||
if (!notify_get_next (&tmp_app))
|
||||
pthread_exit ((void *)0);
|
||||
pthread_exit (NULL);
|
||||
|
||||
if (!tmp_app.got_app)
|
||||
{
|
||||
@ -456,7 +456,7 @@ notify_thread_app (void *arg)
|
||||
mem_free (tmp_app.txt);
|
||||
notify_update_bar ();
|
||||
|
||||
pthread_exit ((void *) 0);
|
||||
pthread_exit (NULL);
|
||||
}
|
||||
|
||||
/* Launch the thread notify_thread_app to look for next appointment. */
|
||||
@ -464,7 +464,7 @@ void
|
||||
notify_check_next_app (int force)
|
||||
{
|
||||
pthread_t notify_t_app;
|
||||
void *arg = (force ? (void *)1 : (void *)0);
|
||||
void *arg = (force ? (void *)1 : NULL);
|
||||
|
||||
pthread_create (¬ify_t_app, &detached_thread_attr, notify_thread_app,
|
||||
arg);
|
||||
|
@ -83,7 +83,7 @@ sigs_set_hdlr (int sig, void (*handler)(int))
|
||||
sigemptyset (&sa.sa_mask);
|
||||
sa.sa_handler = handler;
|
||||
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"),
|
||||
sig, strerror (errno));
|
||||
|
@ -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;
|
||||
|
||||
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)
|
||||
{
|
||||
mvwprintw (popup_win, margin_top, margin_left, "- %s -> %s",
|
||||
@ -557,7 +557,7 @@ new_tempfile (const char *prefix, int trailing_len)
|
||||
close (fd);
|
||||
}
|
||||
ERROR_MSG (_("temporary file \"%s\" could not be created"), fullname);
|
||||
return (char *)0;
|
||||
return NULL;
|
||||
}
|
||||
fclose (file);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user