Skip Menu |

This queue is for tickets about the Event CPAN distribution.

Report information
The Basics
Id: 21984
Status: resolved
Priority: 0/
Queue: Event

People
Owner: Nobody in particular
Requestors: jdhedden [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.06
Fixed in: (no value)



Subject: Compiler warnings
The following compiler warning occur while making Event under Perl 5.8.8 with gcc 3.4.4 gcc -c -Ic -Ilib/Event -DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -Wdeclaration-after-statement -DUSEIMPORTLIB -O3 -pipe -funit-at-a-time -mtune=pentium4m -march=pentium4 -mfpmath=sse -mieee-fp -mmmx -msse -msse2 -DVERSION=\"1.06\" -DXS_VERSION=\"1.06\" "-I/usr/lib/perl5/5.8/cygwin/CORE" Event.c In file included from Event.xs:267: c/typemap.c: In function `event_2sv': c/typemap.c:109: warning: cast from pointer to integer of different size c/typemap.c: In function `sv_2event': c/typemap.c:126: warning: cast to pointer from integer of different size In file included from Event.xs:276: c/var.c: In function `tracevar_r': c/var.c:51: warning: cast to pointer from integer of different size c/var.c: In function `tracevar_w': c/var.c:53: warning: cast to pointer from integer of different size c/var.c: In function `pe_var_start': c/var.c:89: warning: cast from pointer to integer of different size In file included from Event.xs:277: c/signal.c: In function `pe_signal_start': c/signal.c:69: warning: passing arg 3 of `Perl_rsignal' from incompatible pointer type c/signal.c: In function `pe_signal_stop': c/signal.c:79: warning: passing arg 3 of `Perl_rsignal' from incompatible pointer type Event.xs: In function `XS_Event_cache_time_api': Event.xs:398: warning: cast to pointer from integer of different size
From: JPRIT [...] cpan.org
On Mon Oct 09 20:58:05 2006, JDHEDDEN wrote: Show quoted text
> c/typemap.c: In function `event_2sv': > c/typemap.c:109: warning: cast from pointer to integer of different size
Event assumes that a pointer will fit into an IV. So these warnings are harmless. It might be worth adding an assertion(sizeof(IV) >= sizeof(char*)).
From: JDHEDDEN [...] cpan.org
On Tue Oct 10 06:21:51 2006, JPRIT wrote: Show quoted text
> On Mon Oct 09 20:58:05 2006, JDHEDDEN wrote:
> > c/typemap.c: In function `event_2sv': > > c/typemap.c:109: warning: cast from pointer to integer of different size
> > Event assumes that a pointer will fit into an IV. So these warnings are > harmless. > > It might be worth adding an assertion(sizeof(IV) >= sizeof(char*)).
There are macros to do such conversion "the right way". Attached is a patch that corrects all the compiler warnings. I look forward to seeing a clean build with the next release.
diff -urN Event-1.07/Event.xs Event-patched/Event.xs --- Event-1.07/Event.xs 2006-10-10 05:12:05.000000000 -0400 +++ Event-patched/Event.xs 2006-10-10 14:36:19.111234100 -0400 @@ -395,7 +395,7 @@ SV **svp = hv_fetch(PL_modglobal, "Time::NVtime", 12, 0); if (!svp || !*svp || !SvIOK(*svp)) XSRETURN_NO; - api.NVtime = (double(*)()) SvIV(*svp); + api.NVtime = INT2PTR(double(*)(), SvIV(*svp)); XSRETURN_YES; double diff -urN Event-1.07/c/signal.c Event-patched/c/signal.c --- Event-1.07/c/signal.c 2005-01-31 09:41:40.000000000 -0500 +++ Event-patched/c/signal.c 2006-10-10 14:35:19.924357100 -0400 @@ -66,7 +66,7 @@ if (sig == 0) return "without signal"; if (PE_RING_EMPTY(&Sigring[sig])) - rsignal(sig, process_sighandler); + rsignal(sig, (Sighandler_t)process_sighandler); PE_RING_UNSHIFT(&ev->sring, &Sigring[sig]); return 0; } @@ -76,7 +76,7 @@ int sig = ev->signal; PE_RING_DETACH(&ev->sring); if (PE_RING_EMPTY(&Sigring[sig])) { - rsignal(sig, SIG_DFL); + rsignal(sig, (Sighandler_t)SIG_DFL); Sigstat[0].hits[sig] = 0; Sigstat[1].hits[sig] = 0; } diff -urN Event-1.07/c/typemap.c Event-patched/c/typemap.c --- Event-1.07/c/typemap.c 2006-10-10 05:10:19.000000000 -0400 +++ Event-patched/c/typemap.c 2006-10-10 14:25:50.228132900 -0400 @@ -106,7 +106,7 @@ SV *rv = newSV(0); SV *sv = newSVrv(rv,0); sv_bless(rv, ev->vtbl->stash); - sv_setiv(sv, (IV)ev); + sv_setiv(sv, PTR2IV(ev)); ev->mysv = rv; if (WaDEBUGx(ev->up) >= 4) { @@ -123,7 +123,7 @@ assert(sv); assert(SvROK(sv)); sv = SvRV(sv); - ptr = (void*) SvIV(sv); + ptr = INT2PTR(void *, SvIV(sv)); assert(ptr); return ptr; } diff -urN Event-1.07/c/var.c Event-patched/c/var.c --- Event-1.07/c/var.c 2006-10-10 05:11:24.000000000 -0400 +++ Event-patched/c/var.c 2006-10-10 14:39:49.950713200 -0400 @@ -48,9 +48,9 @@ } static I32 tracevar_r(pTHX_ IV ix, SV *sv) -{ pe_tracevar((pe_watcher *)ix, sv, PE_R); return 0; /*ignored*/ } +{ pe_tracevar(INT2PTR(pe_watcher *, ix), sv, PE_R); return 0; /*ignored*/ } static I32 tracevar_w(pTHX_ IV ix, SV *sv) -{ pe_tracevar((pe_watcher *)ix, sv, PE_W); return 0; /*ignored*/ } +{ pe_tracevar(INT2PTR(pe_watcher *, ix), sv, PE_W); return 0; /*ignored*/ } static char *pe_var_start(pe_watcher *_ev, int repeat) { STRLEN n_a; @@ -86,7 +86,7 @@ EvNew(8, ufp, 1, struct ufuncs); ufp->uf_val = ev->events & PE_R? tracevar_r : 0; ufp->uf_set = ev->events & PE_W? tracevar_w : 0; - ufp->uf_index = (IV) ev; + ufp->uf_index = PTR2IV(ev); mg->mg_ptr = (char *) ufp; mg->mg_obj = (SV*) ev;
Subject: Re: [rt.cpan.org #21984] Compiler warnings
Date: Wed, 11 Oct 2006 17:49:08 +0530
To: "Jerry D. Hedden via RT" <bug-Event [...] rt.cpan.org>
From: Joshua N Pritikin <jpritikin [...] pobox.com>
Thanks for the patch. Applied.
Resolved long ago.