From: Kees Jongenburger Date: Mon, 7 Jan 2013 16:19:30 +0000 (+0100) Subject: test:update tests to fix compiler warnings. X-Git-Tag: v3.2.1~141 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch05.html?a=commitdiff_plain;h=5e3b51ba964d05f76cd896e2ef3470fdc4504c8f;p=minix.git test:update tests to fix compiler warnings. Change-Id: Id2c757f61fe5e8b52dffadfeb129024625c76f48 --- diff --git a/test/t40c.c b/test/t40c.c index f4cb5e45b..1302265d1 100644 --- a/test/t40c.c +++ b/test/t40c.c @@ -68,7 +68,6 @@ void open_terminal(int *child_fd, int *parent_fd) { } int do_child(int terminal) { - int retval; struct timeval tv; /* Going to sleep for two seconds to allow the parent proc to get ready */ @@ -77,12 +76,12 @@ int do_child(int terminal) { select(0, NULL, NULL, NULL, &tv); /* Try to write. Doesn't matter how many bytes we actually send. */ - retval = write(terminal, SENDSTRING, strlen(SENDSTRING)); + (void) write(terminal, SENDSTRING, strlen(SENDSTRING)); close(terminal); /* Wait for another second to allow the parent to process incoming data */ tv.tv_usec = 1000000; - retval = select(0,NULL, NULL, NULL, &tv); + (void) select(0,NULL, NULL, NULL, &tv); exit(0); } diff --git a/test/t40d.c b/test/t40d.c index 4a5285484..4834ab17c 100644 --- a/test/t40d.c +++ b/test/t40d.c @@ -61,7 +61,6 @@ void e(int n, char *s) { void do_child(void) { struct timeval tv; - int retval; /* Open named pipe for writing. This will block until a reader arrives. */ if((fd_np1 = open(NAMEDPIPE1, O_WRONLY)) == -1) { @@ -79,19 +78,19 @@ void do_child(void) { select(0, NULL, NULL, NULL, &tv); /* Try to write. Doesn't matter how many bytes we actually send. */ - retval = write(fd_np1, SENDSTRING, strlen(SENDSTRING)); + (void) write(fd_np1, SENDSTRING, strlen(SENDSTRING)); /* Wait for another second to allow the parent to process incoming data */ tv.tv_sec = DO_HANDLEDATA; tv.tv_usec = 0; - retval = select(0,NULL, NULL, NULL, &tv); + (void) select(0,NULL, NULL, NULL, &tv); close(fd_np1); /* Wait for another second to allow the parent to process incoming data */ tv.tv_sec = DO_HANDLEDATA; tv.tv_usec = 0; - retval = select(0,NULL, NULL, NULL, &tv); + (void) select(0,NULL, NULL, NULL, &tv); /* Open named pipe for reading. This will block until a writer arrives. */ if((fd_np2 = open(NAMEDPIPE2, O_RDONLY)) == -1) { @@ -106,7 +105,7 @@ void do_child(void) { /* Wait for another second to allow the parent to run some tests. */ tv.tv_sec = DO_HANDLEDATA; tv.tv_usec = 0; - retval = select(0, NULL, NULL, NULL, &tv); + (void) select(0, NULL, NULL, NULL, &tv); close(fd_np2); @@ -115,7 +114,7 @@ void do_child(void) { /* Let the parent do initial read and write tests from and to the pipe. */ tv.tv_sec = DO_PAUSE; tv.tv_usec = 0; - retval = select(0, NULL, NULL, NULL, &tv); + (void) select(0, NULL, NULL, NULL, &tv); /* Unblock blocking read select by writing data */ if(write(fd_ap[1], SENDSTRING, strlen(SENDSTRING)) < 0) { diff --git a/test/t40f.c b/test/t40f.c index ccdf7d61e..239af96b5 100644 --- a/test/t40f.c +++ b/test/t40f.c @@ -62,12 +62,11 @@ float compute_diff(struct timeval start, struct timeval end, float compare) { void do_child(void) { struct timeval tv; - int retval; /* Let the parent do initial read and write tests from and to the pipe. */ tv.tv_sec = DO_PAUSE + DO_PAUSE + DO_PAUSE + 1; tv.tv_usec = 0; - retval = select(0, NULL, NULL, NULL, &tv); + (void) select(0, NULL, NULL, NULL, &tv); /* At this point the parent has a pending select with a DO_TIMEOUT timeout. We're going to interrupt by sending a signal */ diff --git a/test/test1.c b/test/test1.c index 6160b676f..b5ee190e6 100644 --- a/test/test1.c +++ b/test/test1.c @@ -75,9 +75,7 @@ void parent() void child(i) int i; { - int n; - - n = getpid(); + (void) getpid(); exit(100+i); } diff --git a/test/test10.c b/test/test10.c index 41d574a1b..152b560bf 100644 --- a/test/test10.c +++ b/test/test10.c @@ -72,12 +72,12 @@ int main() void spawn(n) int n; { - int pid, k; + int pid; if ((pid = fork()) != 0) { wait(&n); /* wait for some child (any one) */ } else { - k = execl(name[n], name[n], (char *) 0); + execl(name[n], name[n], (char *) 0); errct++; printf("Child execl didn't take. file=%s errno=%d\n", name[n], errno); rmfiles(); diff --git a/test/test20.c b/test/test20.c index 6ea2ec7db..dcb5b968d 100644 --- a/test/test20.c +++ b/test/test20.c @@ -41,11 +41,9 @@ char executable[1024]; int main(int argc, char *argv[]) { - int i, m = 0xFFFF; + int i; sync(); - if (argc == 2) m = atoi(argv[1]); - /* If we have to check things, call do_check(). */ if (strcmp(argv[0], "DO CHECK") == 0) exit(do_check()); diff --git a/test/test5.c b/test/test5.c index 6ea1093c8..2960d8f27 100644 --- a/test/test5.c +++ b/test/test5.c @@ -210,7 +210,7 @@ void test5e() /* When a signal knocks a processes out of WAIT or PAUSE, it is supposed to * get EINTR as error status. Check that. */ - int n, j; + int n; subtest = 5; if (signal(8, func8) == SIG_ERR) e(25); @@ -222,7 +222,7 @@ void test5e() if (wait(&n) < 0) e(27); if (signal(8, SIG_DFL) == SIG_ERR) e(28); } else { - j = pause(); + (void) pause(); if (errno != EINTR && -errno != EINTR) e(29); exit(0); } @@ -282,7 +282,7 @@ void test5h() /* When a signal knocks a processes out of PIPE, it is supposed to * get EINTR as error status. Check that. */ - int n, j, fd[2]; + int n, fd[2]; subtest = 8; unlink("XXX.test5"); @@ -301,7 +301,7 @@ void test5h() if (close(fd[1]) != 0) e(6); } else { if (creat("XXX.test5", 0777) < 0) e(7); - j = read(fd[0], (char *) &n, 1); + (void) read(fd[0], (char *) &n, 1); if (errno != EINTR) e(8); exit(0); } diff --git a/test/test56.c b/test/test56.c index 360e2a625..973e173bc 100644 --- a/test/test56.c +++ b/test/test56.c @@ -471,10 +471,8 @@ void test_bind(void) int sd; int sd2; int rc; - int on; debug("entering test_bind()"); - on = 1; UNLINK(TEST_SUN_PATH); memset(&addr, '\0', sizeof(struct sockaddr_un)); addr.sun_family = AF_UNIX; @@ -980,9 +978,7 @@ void test_dup2(void) */ void test_xfer_server(pid_t pid) { - socklen_t ucred_length; int i; - int on; struct timeval tv; fd_set readfds; int status; @@ -994,11 +990,9 @@ void test_xfer_server(pid_t pid) struct sockaddr_un addr; struct sockaddr_un client_addr; - on = 1; status = 0; rc = 0; sd = 0; - ucred_length = sizeof(struct ucred); client_sd = 0; client_addr_size = sizeof(struct sockaddr_un); @@ -2481,9 +2475,6 @@ void test_permissions(void) { pid_t pid; int sd, rc, status; struct sockaddr_un addr; - socklen_t client_addr_size; - - client_addr_size = sizeof(struct sockaddr_un); memset(&addr, '\0', sizeof(struct sockaddr_un)); addr.sun_family = AF_UNIX; diff --git a/test/test9.c b/test/test9.c index 035f48e84..67b6042b0 100644 --- a/test/test9.c +++ b/test/test9.c @@ -233,6 +233,18 @@ void level1() p = &buf[10]; i = 200; p = &buf[20]; + +#ifdef __GNUC__ + /* + * to defeat the smartness of the GNU C optimizer we pretend we + * use 'a'. Otherwise the optimizer will not detect the looping + * effectuated by setjmp/longjmp, so that it thinks it can get + * rid of the assignment to 'a'. + */ + srand(i); + srand((int)*p); +#endif + longjmp(env, 2); }