warning: cast from pointer to integer of different size
reedjc opened this issue · comments
On NetBSD I saw:
fltmod/nmsg_flt_sample.c: In function 'sample_thread_init':
fltmod/nmsg_flt_sample.c:223:65: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
uint32_t seed = (unsigned) tv.tv_sec + (unsigned) tv.tv_usec + (unsigned) pthread_self();
I didn't see on LInux, both x86_64 architecture. Both with same sizes of pthread_t and unsigned and int and uintptr_t. (My NetBSD gcc is 5.5.0 and debian gcc is 6.3.0.)
My workaround is:
--- a/fltmod/nmsg_flt_sample.c
+++ b/fltmod/nmsg_flt_sample.c
@@ -220,7 +220,7 @@ sample_thread_init(void *mod_data, void **thr_data)
/* Initialize state->xsubi, seed for this thread's random generator. */
struct timeval tv = {0};
gettimeofday(&tv, NULL);
- uint32_t seed = (unsigned) tv.tv_sec + (unsigned) tv.tv_usec + (unsigned) pthread_self();
+ uint32_t seed = (unsigned) tv.tv_sec + (unsigned) tv.tv_usec + (uintptr_t) pthread_self();
memcpy(state->xsubi, &seed, sizeof(seed));