perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject [PATCH] modperl_restart_count fix
Date Sun, 12 Dec 2004 15:11:17 GMT
Current SVN failed -Werror build on x86_64 due to casting between
integers and pointer types:

modperl_util.c: In function `modperl_restart_count_inc':
modperl_util.c:814: warning: cast from pointer to integer of different size
modperl_util.c:817: warning: cast to pointer from integer of different size
modperl_util.c: In function `modperl_restart_count':
modperl_util.c:826: warning: cast from pointer to integer of different size
make[1]: *** [modperl_util.lo] Error 1
make[1]: Leaving directory `/tmp/regressD22607/mp-2.0/src/modules/perl'

This fixes the warnings and passes the test suite, not tested to DTRT
after a restart:

Index: src/modules/perl/modperl_util.c
===================================================================
--- src/modules/perl/modperl_util.c	(revision 111650)
+++ src/modules/perl/modperl_util.c	(working copy)
@@ -807,15 +807,20 @@
 void modperl_restart_count_inc(server_rec *base_server)
 {
     void *data;
-    int cnt = 1;
+    int *counter;
     apr_pool_t *p = base_server->process->pool;
+    
     apr_pool_userdata_get(&data, MP_RESTART_COUNT_KEY, p);
     if (data) {
-        cnt = (int)data + 1;
+        counter = data;
+        (*counter)++;
     }
-    
-    apr_pool_userdata_set((const void *)cnt, MP_RESTART_COUNT_KEY,
-                          apr_pool_cleanup_null, p);
+    else {
+        counter = apr_palloc(p, sizeof *counter);
+        *counter = 1;
+        apr_pool_userdata_set(counter, MP_RESTART_COUNT_KEY,
+                              apr_pool_cleanup_null, p);
+    }    
 }
 
 int modperl_restart_count(void)
@@ -823,5 +828,5 @@
     void *data;
     apr_pool_userdata_get(&data, MP_RESTART_COUNT_KEY,
                           modperl_global_get_server_rec()->process->pool);
-    return data ? (int)data : 0;
+    return data ? *(int *)data : 0;
  }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message