]> granicus.if.org Git - php/commitdiff
Fix compiler warnings and refcount not being in sync with 5.3
authorKalle Sommer Nielsen <kalle@php.net>
Tue, 19 May 2009 17:38:08 +0000 (17:38 +0000)
committerKalle Sommer Nielsen <kalle@php.net>
Tue, 19 May 2009 17:38:08 +0000 (17:38 +0000)
ext/com_dotnet/com_handlers.c
ext/com_dotnet/com_iterator.c
ext/com_dotnet/com_persist.c
ext/com_dotnet/com_saproxy.c
ext/com_dotnet/com_variant.c
ext/com_dotnet/com_wrapper.c

index a9a37cc2e01e737c0f9cf755e90af5fadc37ead2..399d3902e6a96c64d7127ffbc2e4d3d3ec18cac4 100644 (file)
@@ -259,7 +259,7 @@ static PHP_FUNCTION(com_method_handler)
                        INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
 
-static union _zend_function *com_method_get(zval **object_ptr, char *name, int len TSRMLS_DC)
+static union _zend_function *com_method_get(zval **object_ptr, zstr name, int len TSRMLS_DC)
 {
        zend_internal_function f, *fptr = NULL;
        php_com_dotnet_object *obj;
@@ -273,18 +273,18 @@ static union _zend_function *com_method_get(zval **object_ptr, char *name, int l
                return NULL;
        }
 
-       if (FAILED(php_com_get_id_of_name(obj, name, len, &dummy TSRMLS_CC))) {
+       if (FAILED(php_com_get_id_of_name(obj, name.s, len, &dummy TSRMLS_CC))) {
                return NULL;
        }
 
        /* check cache */
-       if (obj->method_cache == NULL || FAILURE == zend_hash_find(obj->method_cache, name, len, (void**)&fptr)) {
+       if (obj->method_cache == NULL || FAILURE == zend_hash_find(obj->method_cache, name.s, len, (void**)&fptr)) {
                f.type = ZEND_OVERLOADED_FUNCTION;
                f.num_args = 0;
                f.arg_info = NULL;
                f.scope = obj->ce;
                f.fn_flags = 0;
-               f.function_name.s = estrndup(name, len);
+               f.function_name.s = estrndup(name.s, len);
                f.handler = PHP_FN(com_method_handler);
 
                fptr = &f;
@@ -300,7 +300,7 @@ static union _zend_function *com_method_get(zval **object_ptr, char *name, int l
                        int i;
 
                        if (SUCCEEDED(ITypeInfo_GetTypeComp(obj->typeinfo, &comp))) {
-                               olename = php_com_string_to_olestring(name, len, obj->code_page TSRMLS_CC);
+                               olename = php_com_string_to_olestring(name.s, len, obj->code_page TSRMLS_CC);
                                lhash = LHashValOfNameSys(SYS_WIN32, LOCALE_SYSTEM_DEFAULT, olename);
 
                                if (SUCCEEDED(ITypeComp_Bind(comp, olename, lhash, INVOKE_FUNC, &TI, &kind, &bindptr))) {
@@ -348,7 +348,7 @@ static union _zend_function *com_method_get(zval **object_ptr, char *name, int l
                                zend_hash_init(obj->method_cache, 2, NULL, function_dtor, 0);
                        }
 
-                       zend_hash_update(obj->method_cache, name, len, &f, sizeof(f), (void**)&fptr);
+                       zend_hash_update(obj->method_cache, name.s, len, &f, sizeof(f), (void**)&fptr);
                }
        }
 
@@ -364,7 +364,7 @@ static union _zend_function *com_method_get(zval **object_ptr, char *name, int l
        return NULL;
 }
 
-static int com_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS)
+static int com_call_method(zstr method, INTERNAL_FUNCTION_PARAMETERS)
 {
        zval ***args = NULL;
        php_com_dotnet_object *obj;
@@ -387,7 +387,7 @@ static int com_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS)
 
        VariantInit(&v);
 
-       if (SUCCESS == php_com_do_invoke_byref(obj, method, -1, DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, nargs, args TSRMLS_CC)) {
+       if (SUCCESS == php_com_do_invoke_byref(obj, method.s, -1, DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, nargs, args TSRMLS_CC)) {
                php_com_zval_from_variant(return_value, &v, obj->code_page TSRMLS_CC);
                ret = SUCCESS;
                VariantClear(&v);
@@ -434,7 +434,7 @@ static union _zend_function *com_constructor_get(zval *object TSRMLS_DC)
        }
 }
 
-static zend_class_entry *com_class_entry_get(zval *object TSRMLS_DC)
+static zend_class_entry *com_class_entry_get(const zval *object TSRMLS_DC)
 {
        php_com_dotnet_object *obj;
        obj = CDNO_FETCH(object);
@@ -442,12 +442,12 @@ static zend_class_entry *com_class_entry_get(zval *object TSRMLS_DC)
        return obj->ce;
 }
 
-static int com_class_name_get(zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC)
+static int com_class_name_get(const zval *object, zstr *class_name, zend_uint *class_name_len, int parent TSRMLS_DC)
 {
        php_com_dotnet_object *obj;
        obj = CDNO_FETCH(object);
 
-       *class_name = estrndup(obj->ce->name.s, obj->ce->name_length);
+       (*class_name).s = estrndup(obj->ce->name.s, obj->ce->name_length);
        *class_name_len = obj->ce->name_length;
 
        return 0;
@@ -491,7 +491,6 @@ static int com_object_cast(zval *readobj, zval *writeobj, int type, void *extra
        php_com_dotnet_object *obj;
        VARIANT v;
        VARTYPE vt = VT_EMPTY;
-       zval free_obj;
        HRESULT res = S_OK;
 
        obj = CDNO_FETCH(readobj);
index 11a0bd2b320c1cf2bcd86c9a187ea1a43ac1eb65..aad4834a7a3a8406c861637ab4b4fa3567d51a0a 100644 (file)
@@ -74,8 +74,7 @@ static void com_iter_get_data(zend_object_iterator *iter, zval ***data TSRMLS_DC
        *data = &I->zdata;
 }
 
-static int com_iter_get_key(zend_object_iterator *iter, char **str_key, uint *str_key_len,
-       ulong *int_key TSRMLS_DC)
+static int com_iter_get_key(zend_object_iterator *iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
 {
        struct php_com_iterator *I = (struct php_com_iterator*)iter->data;
 
@@ -111,7 +110,7 @@ static int com_iter_move_forwards(zend_object_iterator *iter TSRMLS_DC)
                }
        } else {
                /* safe array */
-               if (I->key >= I->sa_max) {
+               if (I->key >= (unsigned long) I->sa_max) {
                        I->key = (ulong)-1;
                        return FAILURE;
                }
index 61d46d8a0f0f629cbac680a339a04e15a4dccb41..eca23f00d0458eed5647c01efe0a593617d849f6 100755 (executable)
@@ -157,7 +157,7 @@ static HRESULT STDMETHODCALLTYPE stm_seek(IStream *This, LARGE_INTEGER dlibMove,
                return STG_E_INVALIDFUNCTION;
        }
        
-       offset = dlibMove.QuadPart;
+       offset = (off_t) dlibMove.QuadPart;
 
        ret = php_stream_seek(stm->stream, offset, whence);
 
@@ -261,7 +261,7 @@ static void istream_destructor(php_istream *stm)
                return;
        }
 
-       if (Z_REFCOUNT_P(stm) > 0) {
+       if (stm->refcount > 0) {
                CoDisconnectObject((IUnknown*)stm, 0);
        }
 
@@ -275,13 +275,14 @@ PHPAPI IStream *php_com_wrapper_export_stream(php_stream *stream TSRMLS_DC)
 {
        php_istream *stm = (php_istream*)CoTaskMemAlloc(sizeof(*stm));
 
-       if (stm == NULL)
+       if (stm == NULL) {
                return NULL;
+       }
 
        memset(stm, 0, sizeof(*stm));
        stm->engine_thread = GetCurrentThreadId();
        stm->lpVtbl = &php_istream_vtbl;
-       Z_SET_REFCOUNT_P(stm, 1);
+       stm->refcount = 1;
        stm->stream = stream;
 
        zend_list_addref(stream->rsrc_id);
index da7af23dbc1954b06e369eb4a6cbce4be8a8ea65..443cd26d50286688ec48d1fff883700e661c4518 100644 (file)
@@ -92,10 +92,9 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type TSRMLS_
 {
        php_com_saproxy *proxy = SA_FETCH(object);
        zval *return_value;
-       UINT dims;
+       UINT dims, i;
        SAFEARRAY *sa;
        LONG ubound, lbound;
-       int i;
        HRESULT res;
        
        MAKE_STD_ZVAL(return_value);
@@ -110,7 +109,7 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type TSRMLS_
 
                args = safe_emalloc(proxy->dimensions + 1, sizeof(zval *), 0);
 
-               for (i = 1; i < proxy->dimensions; i++) {
+               for (i = 1; i < (UINT) proxy->dimensions; i++) {
                        args[i-1] = proxy->indices[i];
                }
                args[i-1] = offset;
@@ -145,7 +144,7 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type TSRMLS_
        sa = V_ARRAY(&proxy->obj->v);
        dims = SafeArrayGetDim(sa);
 
-       if (proxy->dimensions >= dims) {
+       if ((UINT) proxy->dimensions >= dims) {
                /* too many dimensions */
                php_com_throw_exception(E_INVALIDARG, "too many dimensions!" TSRMLS_CC);
                return return_value;
@@ -212,8 +211,7 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type TSRMLS_
 static void saproxy_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC)
 {
        php_com_saproxy *proxy = SA_FETCH(object);
-       UINT dims;
-       int i;
+       UINT dims, i;
        HRESULT res;
        VARIANT v;
        
@@ -223,7 +221,7 @@ static void saproxy_write_dimension(zval *object, zval *offset, zval *value TSRM
                 * the final value */
                zval **args = safe_emalloc(proxy->dimensions + 2, sizeof(zval *), 0);
 
-               for (i = 1; i < proxy->dimensions; i++) {
+               for (i = 1; i < (UINT) proxy->dimensions; i++) {
                        args[i-1] = proxy->indices[i];
                }
                args[i-1] = offset;
@@ -323,13 +321,13 @@ static HashTable *saproxy_properties_get(zval *object TSRMLS_DC)
        return NULL;
 }
 
-static union _zend_function *saproxy_method_get(zval **object, char *name, int len TSRMLS_DC)
+static union _zend_function *saproxy_method_get(const zval **object, zstr name, int len TSRMLS_DC)
 {
        /* no methods */
        return NULL;
 }
 
-static int saproxy_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS)
+static int saproxy_call_method(zstr method, INTERNAL_FUNCTION_PARAMETERS)
 {
        return FAILURE;
 }
@@ -340,14 +338,14 @@ static union _zend_function *saproxy_constructor_get(zval *object TSRMLS_DC)
        return NULL;
 }
 
-static zend_class_entry *saproxy_class_entry_get(zval *object TSRMLS_DC)
+static zend_class_entry *saproxy_class_entry_get(const zval *object TSRMLS_DC)
 {
        return php_com_saproxy_class_entry;
 }
 
-static int saproxy_class_name_get(zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC)
+static int saproxy_class_name_get(const zval *object, zstr *class_name, zend_uint *class_name_len, int parent TSRMLS_DC)
 {
-       *class_name = estrndup(php_com_saproxy_class_entry->name.s, php_com_saproxy_class_entry->name_length);
+       (*class_name).s = estrndup(php_com_saproxy_class_entry->name.s, php_com_saproxy_class_entry->name_length);
        *class_name_len = php_com_saproxy_class_entry->name_length;
        return 0;
 }
@@ -521,8 +519,7 @@ static void saproxy_iter_get_data(zend_object_iterator *iter, zval ***data TSRML
        *data = ptr_ptr;
 }
 
-static int saproxy_iter_get_key(zend_object_iterator *iter, char **str_key, uint *str_key_len,
-       ulong *int_key TSRMLS_DC)
+static int saproxy_iter_get_key(zend_object_iterator *iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
 {
        php_com_saproxy_iter *I = (php_com_saproxy_iter*)iter->data;
 
index 44af7dd54cbe20636df79e8f15cae6c2d76e3269..4c28c40366aa02d5a53ecf57889a42b8c8e63223 100644 (file)
@@ -38,7 +38,7 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC)
        SAFEARRAYBOUND bound;
        HashPosition pos;
        int keytype;
-       char *strindex;
+       zstr strindex;
        int strindexlen;
        long intindex = -1;
        long max_index = 0;
index 8c927a1f639a36b6c881820df557c5791f42fc9a..b82928a83ef1ae7a8c663be1180055313a4f0dac 100644 (file)
@@ -457,7 +457,7 @@ static struct IDispatchExVtbl php_dispatch_vtbl = {
 static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
 {
        HashPosition pos;
-       char *name = NULL;
+       zstr name;
        zval *tmp;
        int namelen;
        int keytype;
@@ -479,25 +479,25 @@ static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
                        char namebuf[32];
                        if (keytype == HASH_KEY_IS_LONG) {
                                snprintf(namebuf, sizeof(namebuf), "%d", pid);
-                               name = namebuf;
+                               name.s = namebuf;
                                namelen = strlen(namebuf)+1;
                        }
 
                        zend_hash_move_forward_ex(Z_OBJPROP_P(disp->object), &pos);
 
                        /* Find the existing id */
-                       if (zend_hash_find(disp->name_to_dispid, name, namelen, (void**)&tmp) == SUCCESS)
+                       if (zend_hash_find(disp->name_to_dispid, name.s, namelen, (void**)&tmp) == SUCCESS)
                                continue;
 
                        /* add the mappings */
                        MAKE_STD_ZVAL(tmp);
-                       ZVAL_STRINGL(tmp, name, namelen-1, 1);
+                       ZVAL_STRINGL(tmp, name.s, namelen-1, 1);
                        pid = zend_hash_next_free_element(disp->dispid_to_name);
                        zend_hash_index_update(disp->dispid_to_name, pid, (void*)&tmp, sizeof(zval *), NULL);
 
                        MAKE_STD_ZVAL(tmp);
                        ZVAL_LONG(tmp, pid);
-                       zend_hash_update(disp->name_to_dispid, name, namelen, (void*)&tmp, sizeof(zval *), NULL);
+                       zend_hash_update(disp->name_to_dispid, name.s, namelen, (void*)&tmp, sizeof(zval *), NULL);
                }
        }
        
@@ -511,25 +511,25 @@ static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
                        char namebuf[32];
                        if (keytype == HASH_KEY_IS_LONG) {
                                snprintf(namebuf, sizeof(namebuf), "%d", pid);
-                               name = namebuf;
+                               name.s = namebuf;
                                namelen = strlen(namebuf) + 1;
                        }
 
                        zend_hash_move_forward_ex(Z_OBJPROP_P(disp->object), &pos);
 
                        /* Find the existing id */
-                       if (zend_hash_find(disp->name_to_dispid, name, namelen, (void**)&tmp) == SUCCESS)
+                       if (zend_hash_find(disp->name_to_dispid, name.s, namelen, (void**)&tmp) == SUCCESS)
                                continue;
 
                        /* add the mappings */
                        MAKE_STD_ZVAL(tmp);
-                       ZVAL_STRINGL(tmp, name, namelen-1, 1);
+                       ZVAL_STRINGL(tmp, name.s, namelen-1, 1);
                        pid = zend_hash_next_free_element(disp->dispid_to_name);
                        zend_hash_index_update(disp->dispid_to_name, pid, (void*)&tmp, sizeof(zval *), NULL);
 
                        MAKE_STD_ZVAL(tmp);
                        ZVAL_LONG(tmp, pid);
-                       zend_hash_update(disp->name_to_dispid, name, namelen, (void*)&tmp, sizeof(zval *), NULL);
+                       zend_hash_update(disp->name_to_dispid, name.s, namelen, (void*)&tmp, sizeof(zval *), NULL);
                }
        }
 }
@@ -547,7 +547,7 @@ static php_dispatchex *disp_constructor(zval *object TSRMLS_DC)
 
        disp->engine_thread = GetCurrentThreadId();
        disp->lpVtbl = &php_dispatch_vtbl;
-       Z_SET_REFCOUNT_P(disp, 1);
+       disp->refcount = 1;
 
 
        if (object)
@@ -572,8 +572,9 @@ static void disp_destructor(php_dispatchex *disp)
                        
        disp->id = 0;
        
-       if (Z_REFCOUNT_P(disp) > 0)
+       if (disp->refcount > 0) {
                CoDisconnectObject((IUnknown*)disp, 0);
+       }
 
        zend_hash_destroy(disp->dispid_to_name);
        zend_hash_destroy(disp->name_to_dispid);
@@ -591,7 +592,7 @@ PHPAPI IDispatch *php_com_wrapper_export_as_sink(zval *val, GUID *sinkid,
 {
        php_dispatchex *disp = disp_constructor(val TSRMLS_CC);
        HashPosition pos;
-       char *name = NULL;
+       zstr name;
        zval *tmp, **ntmp;
        int namelen;
        int keytype;