From e2f5272dac6e4b41dfe40b4883fc165fdd2761cd Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Mon, 25 Jul 2011 23:40:57 +0000 Subject: [PATCH] Fix cast warning seen on some platforms --- ext/oci8/oci8.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 4512c1f848..d5abe1b9de 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -37,6 +37,13 @@ #include "php_ini.h" #include "ext/standard/php_smart_str.h" +#ifdef HAVE_STDINT_H +#include +#endif +#ifdef PHP_WIN32 +#include "win32/php_stdint.h" +#endif + #if HAVE_OCI8 #if PHP_MAJOR_VERSION > 5 @@ -51,6 +58,14 @@ #include "php_oci8_int.h" #include "zend_hash.h" +#if defined(HAVE_STDINT_H) || defined(PHP_WIN32) +#define OCI8_INT_TO_PTR(I) ((void *)(intptr_t)(I)) +#define OCI8_PTR_TO_INT(P) ((int)(intptr_t)(P)) +#else +#define OCI8_INT_TO_PTR(I) ((void *)(I)) +#define OCI8_PTR_TO_INT(P) ((int)(P)) +#endif + ZEND_DECLARE_MODULE_GLOBALS(oci) #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) /* This "if" allows PECL builds from this file to be portable to older PHP releases */ @@ -1877,7 +1892,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char int type, link; void *ptr; - link = (int) le->ptr; + link = OCI8_PTR_TO_INT(le->ptr); ptr = zend_list_find(link,&type); if (ptr && (type == le_connection)) { connection = (php_oci_connection *)ptr; @@ -2116,7 +2131,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char #else connection->rsrc_id = zend_list_insert(connection, le_connection); #endif - new_le.ptr = (void *)connection->rsrc_id; + new_le.ptr = OCI8_INT_TO_PTR(connection->rsrc_id); new_le.type = le_index_ptr; zend_hash_update(&EG(regular_list), connection->hash_key, strlen(connection->hash_key)+1, (void *)&new_le, sizeof(zend_rsrc_list_entry), NULL); OCI_G(num_links)++; -- 2.40.0