Browse Source

make test-skeleton C89 compliant

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Bernhard Reutner-Fischer 15 years ago
parent
commit
3149763ed4
1 changed files with 7 additions and 4 deletions
  1. 7 4
      test/test-skeleton.c

+ 7 - 4
test/test-skeleton.c

@@ -137,14 +137,15 @@ timeout_handler (int sig __attribute__ ((unused)))
 {
 {
   int killed = 0;
   int killed = 0;
   int status;
   int status;
+  int i;
 
 
   /* Send signal.  */
   /* Send signal.  */
   kill (pid, SIGKILL);
   kill (pid, SIGKILL);
 
 
   /* Wait for it to terminate.  */
   /* Wait for it to terminate.  */
-  int i;
   for (i = 0; i < 5; ++i)
   for (i = 0; i < 5; ++i)
     {
     {
+      struct timespec ts;
       killed = waitpid (pid, &status, WNOHANG|WUNTRACED);
       killed = waitpid (pid, &status, WNOHANG|WUNTRACED);
       if (killed != 0)
       if (killed != 0)
 	break;
 	break;
@@ -153,7 +154,6 @@ timeout_handler (int sig __attribute__ ((unused)))
 	 nanosleep() call return prematurely, all the better.  We
 	 nanosleep() call return prematurely, all the better.  We
 	 won't restart it since this probably means the child process
 	 won't restart it since this probably means the child process
 	 finally died.  */
 	 finally died.  */
-      struct timespec ts;
       ts.tv_sec = 0;
       ts.tv_sec = 0;
       ts.tv_nsec = 100000000;
       ts.tv_nsec = 100000000;
       nanosleep (&ts, NULL);
       nanosleep (&ts, NULL);
@@ -213,6 +213,7 @@ main (int argc, char *argv[])
   int opt;
   int opt;
   unsigned int timeoutfactor = 1;
   unsigned int timeoutfactor = 1;
   pid_t termpid;
   pid_t termpid;
+  char *envstr_timeoutfactor;
 
 
   /* Make uses of freed and uninitialized memory known.  */
   /* Make uses of freed and uninitialized memory known.  */
 #ifdef __MALLOC_STANDARD__
 #ifdef __MALLOC_STANDARD__
@@ -244,7 +245,7 @@ main (int argc, char *argv[])
 
 
   /* If set, read the test TIMEOUTFACTOR value from the environment.
   /* If set, read the test TIMEOUTFACTOR value from the environment.
      This value is used to scale the default test timeout values. */
      This value is used to scale the default test timeout values. */
-  char *envstr_timeoutfactor = getenv ("TIMEOUTFACTOR");
+  envstr_timeoutfactor = getenv ("TIMEOUTFACTOR");
   if (envstr_timeoutfactor != NULL)
   if (envstr_timeoutfactor != NULL)
     {
     {
       char *envstr_conv = envstr_timeoutfactor;
       char *envstr_conv = envstr_timeoutfactor;
@@ -303,6 +304,9 @@ main (int argc, char *argv[])
   if (pid == 0)
   if (pid == 0)
     {
     {
       /* This is the child.  */
       /* This is the child.  */
+#ifdef RLIMIT_DATA
+      struct rlimit data_limit;
+#endif
 #ifdef RLIMIT_CORE
 #ifdef RLIMIT_CORE
       /* Try to avoid dumping core.  */
       /* Try to avoid dumping core.  */
       struct rlimit core_limit;
       struct rlimit core_limit;
@@ -313,7 +317,6 @@ main (int argc, char *argv[])
 
 
 #ifdef RLIMIT_DATA
 #ifdef RLIMIT_DATA
       /* Try to avoid eating all memory if a test leaks.  */
       /* Try to avoid eating all memory if a test leaks.  */
-      struct rlimit data_limit;
       if (getrlimit (RLIMIT_DATA, &data_limit) == 0)
       if (getrlimit (RLIMIT_DATA, &data_limit) == 0)
 	{
 	{
 	  if (TEST_DATA_LIMIT == RLIM_INFINITY)
 	  if (TEST_DATA_LIMIT == RLIM_INFINITY)