Skip to content

Commit

Permalink
Make use of NULL
Browse files Browse the repository at this point in the history
Replace all (type *)0 with NULL

Created with coccinelle patch:

@@
type T;
@@
-(T*)0
+NULL

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
  • Loading branch information
metan-ucw committed Sep 24, 2014
1 parent 8b35601 commit 4e2bab8
Show file tree
Hide file tree
Showing 164 changed files with 299 additions and 299 deletions.
2 changes: 1 addition & 1 deletion pan/ltp-pan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ run_child(struct coll_entry *colle, struct tag_pgrp *active, int quiet_mode,
* cmd directly.
*/
if (strpbrk(c_cmdline, "\"';|<>$\\")) {
execlp("sh", "sh", "-c", c_cmdline, (char *)0);
execlp("sh", "sh", "-c", c_cmdline, NULL);
errlen = sprintf(errbuf,
"pan(%s): execlp of '%s' (tag %s) failed. errno:%d %s",
panname, c_cmdline, colle->name, errno,
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/containers/netns/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int child_fn(void *c1);

int crtchild(char *s1, char *s2)
{
char *cmd[] = { "--", s1, s2, (char *)0 };
char *cmd[] = { "--", s1, s2, NULL };
execve("/bin/sh", cmd, __environ);
fprintf(stderr, "Failed to execve(%s, %s): %m\n", s1, s2);
return 1;
Expand Down
4 changes: 2 additions & 2 deletions testcases/kernel/fs/fsx-linux/fsx-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ int getnum(char *s, char **e)
{
int ret = -1;

*e = (char *)0;
*e = NULL;
ret = strtol(s, e, 0);
if (*e)
switch (**e) {
Expand Down Expand Up @@ -1126,7 +1126,7 @@ int main(int argc, char **argv)
page_size = getpagesize();
page_mask = page_size - 1;

setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
setvbuf(stdout, NULL, _IOLBF, 0); /* line buffered stdout */

while ((ch = getopt(argc, argv,
"b:c:dl:m:no:p:qr:s:t:w:D:I:LN:OP:RS:W"))
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/fs/openfile/openfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,5 @@ void *threads(void *thread_id_)
/* Close file handles and exit */
close_files(fd_list, numfiles);
unlink(filename);
pthread_exit((void *)0);
pthread_exit(NULL);
}
2 changes: 1 addition & 1 deletion testcases/kernel/io/disktest/signals.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void *sig_handler(void *arg)
}
#ifndef WINDOWS
}
return (void *)0;
return NULL;
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/io/stress_cd/stress_cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void *thread(int *parm)
if (debug)
printf("\tThread [%d]: done\n", num);

pthread_exit((void *)0);
pthread_exit(NULL);
return (NULL);
}

Expand Down
6 changes: 3 additions & 3 deletions testcases/kernel/ipc/ipc_stress/signal_test_01.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ int main(int argc, char **argv)
if (sigaltstack(&stack, NULL) < 0)
sys_error("sigaltstack failed", __LINE__);
#else
if (sigstack(&stack, (struct sigstack *)0) < 0)
if (sigstack(&stack, NULL) < 0)
sys_error("sigstack failed", __LINE__);
#endif
/*
Expand Down Expand Up @@ -307,7 +307,7 @@ void init_sig_vec()
//sigaction.sa_mask = 0;
invec.sa_flags = 0;

if (sigaction(i, &invec, (struct sigaction *)0)) {
if (sigaction(i, &invec, NULL)) {
sprintf(errmsg,
"init_sig_vec: sigaction failed on signal (%d)",
i);
Expand Down Expand Up @@ -337,7 +337,7 @@ void init_sig_vec()
#else
invec.sv_onstack = 1;
#endif
if (sigvec(i, &invec, (struct sigvec *)0)) {
if (sigvec(i, &invec, NULL)) {
sprintf(errmsg,
"init_sig_vec: sigvec failed on signal (%d)",
i);
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/mem/mmapstress/mmapstress01.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ unsigned int initrand(void)
*/
srand((unsigned int)getpid());
seed = rand();
srand((unsigned int)time((time_t *) 0));
srand((unsigned int)time(NULL));
seed = (seed ^ rand()) % 100000;
srand48((long int)seed);
return (seed);
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/mem/mmapstress/mmapstress09.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ unsigned int initrand(void)
*/
srand((unsigned int)getpid());
seed = rand();
srand((unsigned int)time((time_t *) 0));
srand((unsigned int)time(NULL));
seed = (seed ^ rand()) % 100000;
srand48((long int)seed);
return (seed);
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/mem/mmapstress/mmapstress10.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ unsigned int initrand(void)
*/
srand((unsigned int)getpid());
seed = rand();
srand((unsigned int)time((time_t *) 0));
srand((unsigned int)time(NULL));
seed = (seed ^ rand()) % 100000;
srand48((long int)seed);
return (seed);
Expand Down
4 changes: 2 additions & 2 deletions testcases/kernel/mem/mtest06/mmap1.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void *map_write_unmap(void *ptr)
}
}

pthread_exit((void *)0);
pthread_exit(NULL);
}

void *read_mem(void *ptr)
Expand Down Expand Up @@ -246,7 +246,7 @@ void *read_mem(void *ptr)
}
}

pthread_exit((void *)0);
pthread_exit(NULL);
}

static void usage(char *progname)
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/mem/mtest06/mmap3.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void *map_write_unmap(void *args)
}
close(fd);
}
pthread_exit((void *)0);
pthread_exit(NULL);
}

/******************************************************************************/
Expand Down
8 changes: 4 additions & 4 deletions testcases/kernel/mem/mtest06/shmat1.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void *shmat_shmdt(void *args)
STR_SHMAT, pthread_self(), fsize);
}

if ((map_address = shmat(shmid, (void *)0, 0))
if ((map_address = shmat(shmid, NULL, 0))
== (void *)-1) {
fprintf(stderr, "shmat_shmat(): map address = %p\n",
map_address);
Expand Down Expand Up @@ -281,7 +281,7 @@ void *shmat_shmdt(void *args)
pthread_exit((void *)-1);
}
}
pthread_exit((void *)0);
pthread_exit(NULL);
}

/******************************************************************************/
Expand Down Expand Up @@ -321,7 +321,7 @@ void *write_to_mem(void *args)
usleep(1);
sched_yield();
}
pthread_exit((void *)0);
pthread_exit(NULL);
}

/******************************************************************************/
Expand Down Expand Up @@ -368,7 +368,7 @@ void *read_from_mem(void *args)
usleep(1);
sched_yield();
}
pthread_exit((void *)0);
pthread_exit(NULL);
}

/******************************************************************************/
Expand Down
4 changes: 2 additions & 2 deletions testcases/kernel/mem/shmt/shmt03.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int main()

/*------------------------------------------------------------*/

if ((cp1 = (char *)shmat(shmid, (void *)0, 0)) == (char *)-1) {
if ((cp1 = (char *)shmat(shmid, NULL, 0)) == (char *)-1) {
perror("shmat");
tst_resm(TFAIL, "shmat Failed: shmid = %d, errno = %d\n",
shmid, errno);
Expand All @@ -91,7 +91,7 @@ int main()

/*------------------------------------------------------------*/

if ((cp2 = (char *)shmat(shmid, (void *)0, 0)) == (char *)-1) {
if ((cp2 = (char *)shmat(shmid, NULL, 0)) == (char *)-1) {
perror("shmat");
tst_resm(TFAIL, "shmat Failed: shmid = %d, errno = %d\n",
shmid, errno);
Expand Down
4 changes: 2 additions & 2 deletions testcases/kernel/mem/shmt/shmt08.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ int main()
tst_exit();
}

cp = (char *)shmat(shmid, (void *)0, 0);
cp = (char *)shmat(shmid, NULL, 0);
if (cp == (char *)-1) {
tst_resm(TFAIL, "shmat1 Failed");
rm_shm(shmid);
tst_exit();
}

cp1 = (char *)shmat(shmid, (void *)0, 0);
cp1 = (char *)shmat(shmid, NULL, 0);
if (cp1 == (char *)-1) {
perror("shmat2");
rm_shm(shmid);
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/mem/shmt/shmt09.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int main()
tst_exit();
}

c1 = (char *)shmat(shmid, (void *)0, 0);
c1 = (char *)shmat(shmid, NULL, 0);
if (c1 == (char *)-1) {
perror("shmat");
tst_resm(TFAIL,
Expand Down
4 changes: 2 additions & 2 deletions testcases/kernel/mem/shmt/shmt10.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ char *argv[];
}

for (i = 0; i < iter; i++) {
if ((c1 = (char *)shmat(shmid, (void *)0, 0)) == (char *)-1) {
if ((c1 = (char *)shmat(shmid, NULL, 0)) == (char *)-1) {
tst_resm(TFAIL,
"Error shmat: iter %d, shmid = %d\n", i,
shmid);
Expand Down Expand Up @@ -153,7 +153,7 @@ int iter;
char *c1;

for (i = 0; i < iter; i++) {
if ((c1 = (char *)shmat(shmid, (void *)0, 0)) == (char *)-1) {
if ((c1 = (char *)shmat(shmid, NULL, 0)) == (char *)-1) {
tst_resm(TFAIL,
"Error:child proc: shmat: iter %d, shmid = %d\n",
i, shmid);
Expand Down
6 changes: 3 additions & 3 deletions testcases/kernel/pty/pty01.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static void test2(void)
}

slavename = ptsname(masterfd);
if (slavename == (char *)0) {
if (slavename == NULL) {
tst_brkm(TBROK | TERRNO, NULL, "ptsname() call failed");
}

Expand Down Expand Up @@ -267,7 +267,7 @@ static void test3(void)
tst_brkm(TBROK, NULL, MASTERCLONE);
}

if (ioctl(masterfd, TIOCGWINSZ, (char *)0) == 0) {
if (ioctl(masterfd, TIOCGWINSZ, NULL) == 0) {
tst_brkm(TFAIL | TERRNO, NULL,
"trying TIOCGWINSZ on master with no open slave "
"succeeded unexpectedly");
Expand All @@ -293,7 +293,7 @@ static void test4(void)
}

slavename = ptsname(masterfd);
if (slavename == (char *)0) {
if (slavename == NULL) {
tst_resm(TBROK, "ptsname() call failed");
tst_exit();
}
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/sched/clisrv/pthserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,5 @@ void *new_thread(void *arg_)
#else
sched_yield();
#endif
pthread_exit((void *)0);
pthread_exit(NULL);
}
6 changes: 3 additions & 3 deletions testcases/kernel/sched/sched_stress/sched_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ int main(int argc, char **argv)
* Calculate number of seconds to run, then print out start info
*/
runseconds = (long)(execution_time * 60.0 * 60.0);
start_time = time((long *)0);
start_time = time(NULL);

startup(start_time);

Expand Down Expand Up @@ -446,7 +446,7 @@ float *t2; /* if sched_tc6: second time returned from testcase */
*/
if (debug)
printf("waiting on child %d\n", saved_pid);
while (wait((void *)0) != saved_pid) ;
while (wait(NULL) != saved_pid) ;

/*
* Open the temporary file to get the returned number of seconds
Expand Down Expand Up @@ -739,7 +739,7 @@ long start_time; /* starting time to calculate elapsed time */
/*
* Get the end time and calculate elapsed time; write all this out
*/
end_time = time((long *)0);
end_time = time(NULL);

printf("\nend time = %s\n", ctime(&end_time));

Expand Down
6 changes: 3 additions & 3 deletions testcases/kernel/sched/sched_stress/sched_tc0.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ int main(int argc, char **argv)
* Continuously read through file as time permits...
*/
i = 0;
start_time = time((long *)0);
start_time = time(NULL);

if (debug)
printf("\n");
while ((time((long *)0) - start_time) < execution_time) {
while ((time(NULL) - start_time) < execution_time) {
if (debug) {
printf("\r\tprocessing file [%d], time left: %ld",
i++,
execution_time - (time((long *)0) - start_time));
execution_time - (time(NULL) - start_time));
fflush(stdout);
}
process_file(filename);
Expand Down
6 changes: 3 additions & 3 deletions testcases/kernel/sched/sched_stress/sched_tc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ int main(int argc, char **argv)
* Continuously multiply matrix as time permits...
*/
i = 0;
start_time = time((long *)0);
start_time = time(NULL);

if (debug)
printf("\n");
while ((time((long *)0) - start_time) < execution_time) {
while ((time(NULL) - start_time) < execution_time) {
if (debug) {
printf("\r\tmultiplying matrix [%d], time left: %ld",
i++,
execution_time - (time((long *)0) - start_time));
execution_time - (time(NULL) - start_time));
fflush(stdout);
}
multiply_matrices();
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/sched/sched_stress/sched_tc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ int main(int argc, char **argv)
* Continuously multiply matrix as time permits...
*/
i = 0;
start_time = time((long *)0);
start_time = time(NULL);

/*
* Continuously read through file until interrupted...
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/sched/sched_stress/sched_tc6.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ int main(int argc, char **argv)
("parent waiting on child process %d to complete\n",
pid);

while ((rc = wait((void *)0)) != pid)
while ((rc = wait(NULL)) != pid)
if (rc == -1)
sys_error("wait failed", __FILE__, __LINE__);
/*
Expand Down
4 changes: 2 additions & 2 deletions testcases/kernel/syscalls/connect/connect01.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ void do_child(void)

memcpy(&rfds, &afds, sizeof(rfds));

if (select(nfds, &rfds, (fd_set *) 0, (fd_set *) 0,
(struct timeval *)0) < 0)
if (select(nfds, &rfds, NULL, NULL,
NULL) < 0)
if (errno != EINTR)
exit(1);
if (FD_ISSET(sfd, &rfds)) {
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/syscalls/getpeername/getpeername01.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct test_case_t {
#ifndef UCLINUX
{-1, (struct sockaddr *)-1, &sinlen, -1, EFAULT, setup4, cleanup4,
"EFAULT"},
{-1, (struct sockaddr *)&fsin1, (socklen_t *)0, -1, EFAULT, setup4,
{-1, (struct sockaddr *)&fsin1, NULL, -1, EFAULT, setup4,
cleanup4, "EFAULT"},
{-1, (struct sockaddr *)&fsin1, (socklen_t *)1, -1, EFAULT, setup4,
cleanup4, "EFAULT"},
Expand Down
4 changes: 2 additions & 2 deletions testcases/kernel/syscalls/getsockname/getsockname01.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ struct test_case_t { /* test case structure */
#ifndef UCLINUX
/* Skip since uClinux does not implement memory protection */
{
PF_INET, SOCK_STREAM, 0, (struct sockaddr *)0,
PF_INET, SOCK_STREAM, 0, NULL,
&sinlen, -1, EFAULT, setup1, cleanup1,
"invalid socket buffer"}, {
/* invalid salen test for aligned input */
PF_INET, SOCK_STREAM, 0, (struct sockaddr *)&fsin1,
(socklen_t *) 0, -1, EFAULT, setup1, cleanup1,
NULL, -1, EFAULT, setup1, cleanup1,
"invalid aligned salen"}, {
/* invalid salen test for unaligned input */
PF_INET, SOCK_STREAM, 0, (struct sockaddr *)&fsin1,
Expand Down
Loading

0 comments on commit 4e2bab8

Please sign in to comment.