Bug 1588712 - Remove some useless declarations. r=kaie
authorSylvestre Ledru <sledru@mozilla.com>
Sun, 27 Oct 2019 16:40:02 +0100
changeset 4844 f5796065b9e239add3c5120941fd0438288faf67
parent 4842 f036f840e3197914014c7cc6a164781d8f71cb5b
child 4845 65cf6029a830ab5c8648ede6ff49b1c27fb5c9cc
push id342
push userkaie@kuix.de
push dateSun, 27 Oct 2019 15:40:38 +0000
reviewerskaie
bugs1588712
Bug 1588712 - Remove some useless declarations. r=kaie
pr/tests/forktest.c
pr/tests/multiwait.c
pr/tests/sel_spd.c
pr/tests/zerolen.c
--- a/pr/tests/forktest.c
+++ b/pr/tests/forktest.c
@@ -194,34 +194,33 @@ finish:
         PR_Close(sock);
     }
     return;
 }
 
 int main(int argc, char **argv)
 {
     pid_t pid;
-    int rv;
 
     /* main test program */
 
     DoIO();
 
     pid = fork();
 
     if (pid  == (pid_t) -1) {
         fprintf(stderr, "Fork failed: errno %d\n", errno);
         failed_already=1;
         return 1;
     } else if (pid > 0) {
         int childStatus;
 
         printf("Fork succeeded.  Parent process continues.\n");
         DoIO();
-        if ((rv = waitpid(pid, &childStatus, 0)) != pid) {
+        if (waitpid(pid, &childStatus, 0) != pid) {
             {
                 fprintf(stderr, "waitpid failed: %d\n", errno);
                 failed_already = 1;
             }
         } else if (!WIFEXITED(childStatus)
                    || WEXITSTATUS(childStatus) != 0) {
             failed_already = 1;
         }
--- a/pr/tests/multiwait.c
+++ b/pr/tests/multiwait.c
@@ -701,18 +701,17 @@ static void RunThisOne(
         func(shared);  /* run the test */
         MW_ASSERT(0 == desc_allocated);
         DestroyShared(shared);
     }
 }  /* RunThisOne */
 
 static Verbosity ChangeVerbosity(Verbosity verbosity, PRIntn delta)
 {
-    PRIntn verbage = (PRIntn)verbosity;
-    return (Verbosity)(verbage += delta);
+    return (Verbosity)(((PRIntn)verbosity) + delta)
 }  /* ChangeVerbosity */
 
 int main(int argc, char **argv)
 {
     PLOptStatus os;
     const char *test_name = NULL;
     PLOptState *opt = PL_CreateOptState(argc, argv, "dqGc:o:p:t:w:");
 
--- a/pr/tests/sel_spd.c
+++ b/pr/tests/sel_spd.c
@@ -81,17 +81,16 @@ void
     }
     PR_ExitMonitor(exit_cv);
 }
 
 void
 _server_thread(void *arg_id)
 {
     void _client_thread(void *);
-    PRThread *thread;
     int *id =  (int *)arg_id;
     PRFileDesc *sock;
     PRSocketOptionData sockopt;
     PRNetAddr sa;
     PRFileDesc * newsock;
     char *data_buffer = NULL;
     int data_buffer_size;
     int index;
@@ -137,23 +136,23 @@ void
     }
 
     if ( PR_Listen(sock, 32) < 0 ) {
         fprintf(stderr, "Error listening to socket in server thread %d\n", *id);
         goto done;
     }
 
     /* Tell the client to start */
-    if ( (thread = PR_CreateThread(PR_USER_THREAD,
-                                   _client_thread,
-                                   id,
-                                   PR_PRIORITY_NORMAL,
-                                   scope2,
-                                   PR_UNJOINABLE_THREAD,
-                                   0)) == NULL) {
+    if ( PR_CreateThread(PR_USER_THREAD,
+                         _client_thread,
+                         id,
+                         PR_PRIORITY_NORMAL,
+                         scope2,
+                         PR_UNJOINABLE_THREAD,
+                         0) == NULL) {
         fprintf(stderr, "Error creating client thread %d\n", *id);
     }
 
     for (index = 0; index< _iterations; index++) {
 
 #ifdef DEBUG
         fprintf(stdout, "server thread %d loop %d\n", *id, index);
 #endif
@@ -329,28 +328,27 @@ done:
 
 static
 void do_work(void)
 {
     int index;
 
     _thread_exit_count = _threads * 2;
     for (index=0; index<_threads; index++) {
-        PRThread *thread;
         int *id = (int *)PR_Malloc(sizeof(int));
 
         *id = index;
 
-        if ( (thread = PR_CreateThread(PR_USER_THREAD,
-                                       _server_thread,
-                                       id,
-                                       PR_PRIORITY_NORMAL,
-                                       scope1,
-                                       PR_UNJOINABLE_THREAD,
-                                       0)) == NULL) {
+        if ( PR_CreateThread(PR_USER_THREAD,
+                             _server_thread,
+                             id,
+                             PR_PRIORITY_NORMAL,
+                             scope1,
+                             PR_UNJOINABLE_THREAD,
+                             0) == NULL) {
             fprintf(stderr, "Error creating server thread %d\n", index);
         }
     }
 
     PR_EnterMonitor(exit_cv);
     while (_thread_exit_count > 0) {
         PR_Wait(exit_cv, PR_INTERVAL_NO_TIMEOUT);
     }
--- a/pr/tests/zerolen.c
+++ b/pr/tests/zerolen.c
@@ -67,17 +67,17 @@ static void ClientThread(void *arg)
      */
     if (PR_Sleep(PR_SecondsToInterval(5)) == PR_FAILURE) {
         fprintf(stderr, "PR_Sleep failed\n");
         exit(1);
     }
     /*
      * Then start reading.
      */
-    while ((nbytes = PR_Read(sock, buf, sizeof(buf))) > 0) {
+    while (nbytes = PR_Read(sock, buf, sizeof(buf)) > 0) {
         /* empty loop body */
     }
     if (-1 == nbytes) {
         fprintf(stderr, "PR_Read failed\n");
         exit(1);
     }
     if (PR_Close(sock) == PR_FAILURE) {
         fprintf(stderr, "PR_Close failed\n");
@@ -131,17 +131,17 @@ int main()
         exit(1);
     }
     acceptSock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);
     if (NULL == acceptSock) {
         fprintf(stderr, "PR_Accept failed\n");
         exit(1);
     }
     osfd = PR_FileDesc2NativeHandle(acceptSock);
-    while ((nbytes = write(osfd, buf, sizeof(buf))) != -1) {
+    while (write(osfd, buf, sizeof(buf)) != -1) {
         /* empty loop body */
     }
     if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) {
         fprintf(stderr, "write failed\n");
         exit(1);
     }
     iov.iov_base = buf;
     iov.iov_len = 0;
@@ -172,17 +172,17 @@ int main()
         exit(1);
     }
     acceptSock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);
     if (NULL == acceptSock) {
         fprintf(stderr, "PR_Accept failed\n");
         exit(1);
     }
     osfd = PR_FileDesc2NativeHandle(acceptSock);
-    while ((nbytes = write(osfd, buf, sizeof(buf))) != -1) {
+    while (write(osfd, buf, sizeof(buf)) != -1) {
         /* empty loop body */
     }
     if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) {
         fprintf(stderr, "write failed\n");
         exit(1);
     }
     printf("calling PR_Write with a zero-length buffer\n");
     fflush(stdout);
@@ -211,17 +211,17 @@ int main()
         exit(1);
     }
     acceptSock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);
     if (NULL == acceptSock) {
         fprintf(stderr, "PR_Accept failed\n");
         exit(1);
     }
     osfd = PR_FileDesc2NativeHandle(acceptSock);
-    while ((nbytes = write(osfd, buf, sizeof(buf))) != -1) {
+    while (write(osfd, buf, sizeof(buf)) != -1) {
         /* empty loop body */
     }
     if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) {
         fprintf(stderr, "write failed\n");
         exit(1);
     }
     printf("calling PR_Send with a zero-length buffer\n");
     fflush(stdout);