I noticed a few warnings in testreslist.c in apr-util. Here's a patch to fix them. Some are similar to the warnings Joe Orton fixed in revision 76117, and the other is from calling time when the prototype hasn't been pulled in.

-garrett
Fix two warnings about type punned pointers and strict aliasing on gcc 3.3.4
and pull in time.h if it exists so we can avoid warnings when calling time.

Index: test/testreslist.c
===================================================================
--- test/testreslist.c  (revision 65537)
+++ test/testreslist.c  (working copy)
@@ -15,9 +15,14 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+
 #include "apr_reslist.h"
 #include "apr_thread_proc.h"
 
+#if APR_HAVE_TIME_H
+#include <time.h>
+#endif /* APR_HAVE_TIME_H */
+
 #if !APR_HAS_THREADS
 
 int main(void)
@@ -100,12 +105,14 @@
 
     for (i = 0; i < CONSUMER_ITERATIONS; i++) {
         my_resource_t *res;
-        rv = apr_reslist_acquire(rl, (void**)&res);
+        void *vp;
+        rv = apr_reslist_acquire(rl, &vp);
         if (rv != APR_SUCCESS) {
             fprintf(stderr, "Failed to retrieve resource from reslist\n");
             apr_thread_exit(thd, rv);
             return NULL;
         }
+        res = vp;
         printf("  [tid:%d,iter:%d] using resource id:%d\n", thread_info->tid,
                i, res->id);
         apr_sleep(thread_info->work_delay_sleep);
@@ -136,6 +143,7 @@
     apr_status_t rv;
     my_resource_t *resources[RESLIST_HMAX];
     my_resource_t *res;
+    void *vp;
     int i;
 
     printf("Setting timeout to 1000us: ");
@@ -157,12 +165,13 @@
     }
 
     /* next call will block until timeout is reached */
-    rv = apr_reslist_acquire(rl, (void **)&res);
+    rv = apr_reslist_acquire(rl, &vp);
     if (!APR_STATUS_IS_TIMEUP(rv)) {
         fprintf(stderr, "apr_reslist_acquire()->%d instead of TIMEUP\n", 
                 rv);
         exit(1);
     }
+    res = vp;
 
     /* release the resources; otherwise the destroy operation
      * will blow

Reply via email to