Subject: | PATCH: compile warnings: 'warning: cast to pointer from integer of different size' |
When I run 'make' on FreeBSD 6, I get the following types of warnings:
Statgrab.c: In function `XS_Unix__Statgrab__sort_procs_by_name':
Statgrab.c:660: warning: cast to pointer from integer of different size
Statgrab.c:661: warning: cast to pointer from integer of different size
...
I have attached a patch to fix these compile warnings.
Subject: | 03.Unix-Statgrab-0.04.tar.gz.fix_warnings.patch |
diff -Naur ../Unix-Statgrab-0.04.orig/Statgrab.xs ../Unix-Statgrab-0.04/Statgrab.xs
--- ../Unix-Statgrab-0.04.orig/Statgrab.xs Wed Sep 21 23:29:31 2005
+++ ../Unix-Statgrab-0.04/Statgrab.xs Mon Dec 3 04:32:11 2007
@@ -1320,7 +1320,7 @@
char *meth;
PPCODE:
{
- sg_process_stats_my *self = (sg_process_stats_my*)SvIV(SvRV(obj));
+ sg_process_stats_my *self = INT2PTR( sg_process_stats_my*, SvIV((SV*)SvRV(obj)));
if (strEQ(meth, "name"))
qsort(self->stats, self->nprocs, sizeof(*self->stats), sg_process_compare_name);
diff -Naur ../Unix-Statgrab-0.04.orig/typemap ../Unix-Statgrab-0.04/typemap
--- ../Unix-Statgrab-0.04.orig/typemap Mon Sep 19 23:11:38 2005
+++ ../Unix-Statgrab-0.04/typemap Mon Dec 3 04:32:20 2007
@@ -21,7 +21,12 @@
INPUT
O_OBJECT
- $var = ($type)SvIV((SV*)SvRV( $arg ));
+ if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) )
+ $var = INT2PTR( $type, SvIV((SV*)SvRV( $arg )));
+ else{
+ warn(\"${Package}::$func_name() -- $var is not a blessed SV reference\");
+ XSRETURN_UNDEF;
+ }
OUTPUT
T_NV