]> granicus.if.org Git - php/commitdiff
fix datatype mismatches
authorAnatol Belski <ab@php.net>
Tue, 28 Oct 2014 09:43:58 +0000 (10:43 +0100)
committerAnatol Belski <ab@php.net>
Tue, 28 Oct 2014 16:25:00 +0000 (17:25 +0100)
ext/com_dotnet/com_com.c
ext/com_dotnet/com_handlers.c
ext/com_dotnet/com_olechar.c
ext/com_dotnet/com_persist.c
ext/com_dotnet/com_saproxy.c
ext/com_dotnet/com_typeinfo.c
ext/com_dotnet/com_variant.c
ext/com_dotnet/com_wrapper.c
ext/com_dotnet/php_com_dotnet_internal.h

index 5f0b8ff69790587a6367ee0ff11b8d1c05d5d899..ec276ee00403d571c5a894508575545379d08488 100644 (file)
@@ -129,11 +129,11 @@ PHP_FUNCTION(com_create_instance)
 
                if (user_name) {
                        authid.User = php_com_string_to_olestring(user_name, -1, obj->code_page TSRMLS_CC);
-                       authid.UserLength = user_name_len;
+                       authid.UserLength = (ULONG)user_name_len;
 
                        if (password) {
                                authid.Password = (OLECHAR*)password;
-                               authid.PasswordLength = password_len;
+                               authid.PasswordLength = (ULONG)password_len;
                        } else {
                                authid.Password = (OLECHAR*)"";
                                authid.PasswordLength = 0;
@@ -141,7 +141,7 @@ PHP_FUNCTION(com_create_instance)
 
                        if (domain_name) {
                                authid.Domain = (OLECHAR*)domain_name;
-                               authid.DomainLength = domain_name_len;
+                               authid.DomainLength = (ULONG)domain_name_len;
                        } else {
                                authid.Domain = (OLECHAR*)"";
                                authid.DomainLength = 0;
@@ -288,7 +288,7 @@ PHP_FUNCTION(com_get_active_object)
 {
        CLSID clsid;
        char *module_name;
-       int module_name_len;
+       size_t module_name_len;
        zend_long code_page = COMG(code_page);
        IUnknown *unk = NULL;
        IDispatch *obj = NULL;
@@ -302,7 +302,7 @@ PHP_FUNCTION(com_get_active_object)
                return;
        }
 
-       module = php_com_string_to_olestring(module_name, module_name_len, code_page TSRMLS_CC);
+       module = php_com_string_to_olestring(module_name, module_name_len, (int)code_page TSRMLS_CC);
 
        res = CLSIDFromString(module, &clsid);
 
@@ -320,7 +320,7 @@ PHP_FUNCTION(com_get_active_object)
                                php_com_throw_exception(res, NULL TSRMLS_CC);
                        } else if (obj) {
                                /* we got our dispatchable object */
-                               php_com_wrap_dispatch(return_value, obj, code_page TSRMLS_CC);
+                               php_com_wrap_dispatch(return_value, obj, (int)code_page TSRMLS_CC);
                        }
                }
        }
@@ -427,7 +427,7 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
        }
 
        if (obj->id_of_name_cache && NULL != (tmp = zend_hash_str_find(obj->id_of_name_cache, name, namelen))) {
-               *dispid = Z_LVAL_P(tmp);
+               *dispid = (DISPID)Z_LVAL_P(tmp);
                return S_OK;
        }
        
@@ -631,7 +631,7 @@ int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid,
        return SUCCEEDED(hr) ? SUCCESS : FAILURE;
 }
 
-int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen,
+int php_com_do_invoke(php_com_dotnet_object *obj, char *name, size_t namelen,
                WORD flags,     VARIANT *v, int nargs, zval *args, int allow_noarg TSRMLS_DC)
 {
        DISPID dispid;
@@ -791,7 +791,7 @@ PHP_FUNCTION(com_message_pump)
                RETURN_FALSE;
        
        php_com_initialize(TSRMLS_C);
-       result = MsgWaitForMultipleObjects(0, NULL, FALSE, timeoutms, QS_ALLINPUT);
+       result = MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD)timeoutms, QS_ALLINPUT);
 
        if (result == WAIT_OBJECT_0) {
                while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
index 6f63a1fbd8888a9a202a936e35bccafbae7c9419..8b721393fd8a1fa912c2f9f90d33f4cf665e8562 100644 (file)
@@ -101,7 +101,7 @@ static zval *com_read_dimension(zval *object, zval *offset, int type, zval *rv T
                convert_to_long(offset);
 
                if (SafeArrayGetDim(V_ARRAY(&obj->v)) == 1) {   
-                       if (php_com_safearray_get_elem(&obj->v, &v, Z_LVAL_P(offset) TSRMLS_CC)) {
+                       if (php_com_safearray_get_elem(&obj->v, &v, (LONG)Z_LVAL_P(offset) TSRMLS_CC)) {
                                php_com_wrap_variant(rv, &v, obj->code_page TSRMLS_CC);
                                VariantClear(&v);
                        }
@@ -145,7 +145,7 @@ static void com_write_dimension(zval *object, zval *offset, zval *value TSRMLS_D
                        }
 
                        convert_to_long(offset);
-                       indices = Z_LVAL_P(offset);
+                       indices = (LONG)Z_LVAL_P(offset);
 
                        VariantInit(&v);
                        php_com_variant_from_zval(&v, value, obj->code_page TSRMLS_CC);
index 51cc7e8f1df99883f4dde029b7868b87b5785e1c..2e0b558288a0adb24f81aa665ca537b561b50320 100644 (file)
@@ -49,7 +49,7 @@ PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, size_t str
                /* XXX if that's a real multibyte string, olestring is obviously allocated excessively.
                This should be fixed by reallocating the olestring, but as emalloc is used, that doesn't
                matter much. */
-               ok = MultiByteToWideChar(codepage, flags, string, string_len, olestring, string_len);
+               ok = MultiByteToWideChar(codepage, flags, string, (int)string_len, olestring, (int)string_len);
                if (ok > 0 && ok < string_len) {
                        olestring[ok] = '\0';
                }
index eb80e760c8a0a17420b0aadd8365bff4c22934b5..dbe8b45300483e8b0a910e6675df9df0f7e627ae 100644 (file)
@@ -105,10 +105,10 @@ static ULONG STDMETHODCALLTYPE stm_release(IStream *This)
 
 static HRESULT STDMETHODCALLTYPE stm_read(IStream *This, void *pv, ULONG cb, ULONG *pcbRead)
 {
-       int nread;
+       ULONG nread;
        FETCH_STM();
 
-       nread = php_stream_read(stm->stream, pv, cb);
+       nread = (ULONG)php_stream_read(stm->stream, pv, cb);
 
        if (pcbRead) {
                *pcbRead = nread > 0 ? nread : 0;
@@ -121,10 +121,10 @@ static HRESULT STDMETHODCALLTYPE stm_read(IStream *This, void *pv, ULONG cb, ULO
 
 static HRESULT STDMETHODCALLTYPE stm_write(IStream *This, void const *pv, ULONG cb, ULONG *pcbWritten)
 {
-       int nwrote;
+       ULONG nwrote;
        FETCH_STM();
 
-       nwrote = php_stream_write(stm->stream, pv, cb);
+       nwrote = (ULONG)php_stream_write(stm->stream, pv, cb);
 
        if (pcbWritten) {
                *pcbWritten = nwrote > 0 ? nwrote : 0;
@@ -466,7 +466,7 @@ CPH_METHOD(LoadFromFile)
                olefilename = php_com_string_to_olestring(fullpath, strlen(fullpath), helper->codepage TSRMLS_CC);
                efree(fullpath);
                        
-               res = IPersistFile_Load(helper->ipf, olefilename, flags);
+               res = IPersistFile_Load(helper->ipf, olefilename, (DWORD)flags);
                efree(olefilename);
 
                if (FAILED(res)) {
index ddee9bc179596a28eca84f406a6f43a98d3e235b..1d187a77bf391f4d52308d7240ac08b8774214f4 100644 (file)
@@ -167,11 +167,11 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval *
                /* copy indices from proxy */
                for (i = 0; i < dims; i++) {
                        convert_to_long(&proxy->indices[i]);
-                       indices[i] = Z_LVAL(proxy->indices[i]);
+                       indices[i] = (LONG)Z_LVAL(proxy->indices[i]);
                }
 
                /* add user-supplied index */
-               indices[dims-1] = Z_LVAL_P(offset);
+               indices[dims-1] = (LONG)Z_LVAL_P(offset);
 
                /* now fetch the value */
                if (FAILED(SafeArrayGetVartype(sa, &vt)) || vt == VT_EMPTY) {
@@ -241,12 +241,12 @@ static void saproxy_write_dimension(zval *object, zval *offset, zval *value TSRM
                /* copy indices from proxy */
                for (i = 0; i < dims; i++) {
                        convert_to_long(&proxy->indices[i]);
-                       indices[i] = Z_LVAL(proxy->indices[i]);
+                       indices[i] = (LONG)Z_LVAL(proxy->indices[i]);
                }
 
                /* add user-supplied index */
                convert_to_long(offset);
-               indices[dims-1] = Z_LVAL_P(offset);
+               indices[dims-1] = (LONG)Z_LVAL_P(offset);
 
                if (FAILED(SafeArrayGetVartype(V_ARRAY(&proxy->obj->v), &vt)) || vt == VT_EMPTY) {
                        vt = V_VT(&proxy->obj->v) & ~VT_ARRAY;
@@ -555,7 +555,7 @@ zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *objec
        I->indices = safe_emalloc(proxy->dimensions + 1, sizeof(LONG), 0);
        for (i = 0; i < proxy->dimensions; i++) {
                convert_to_long(&proxy->indices[i]);
-               I->indices[i] = Z_LVAL(proxy->indices[i]);
+               I->indices[i] = (LONG)Z_LVAL(proxy->indices[i]);
        }
 
        SafeArrayGetLBound(V_ARRAY(&proxy->obj->v), proxy->dimensions, &I->imin);
index 33b1c65c9cadfae2a1b327ba89611c25a0264754..17b69d2460ec71019481804dce9c5b96c0c554e4 100644 (file)
@@ -116,7 +116,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep
                                                                        continue;
                                                                }
                                                                /* get the default value for this key and compare */
-                                                               libnamelen = strlen(search_string)+1;
+                                                               libnamelen = (DWORD)strlen(search_string)+1;
                                                                if (ERROR_SUCCESS == RegQueryValue(hsubkey, version, libname, &libnamelen)) {
                                                                        if (0 == stricmp(libname, search_string)) {
                                                                                char *str = NULL;
@@ -234,7 +234,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string,
 {
        ITypeLib *TL;
        char *name_dup;
-       int l;
+       size_t l;
 
        l = strlen(search_string);
 
index dbd5529f6d9b37625ff30b91295636947233cd77..2b91d28daf68e3389705f6a3bbe6c423d13446fa 100644 (file)
@@ -62,7 +62,7 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC)
 
        /* allocate the structure */    
        bound.lLbound = 0;
-       bound.cElements = intindex + 1;
+       bound.cElements = (ULONG)(intindex + 1);
        sa = SafeArrayCreate(VT_VARIANT, 1, &bound);
 
        /* get a lock on the array itself */
@@ -146,8 +146,13 @@ PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codep
                        break;
 
                case IS_LONG:
+#if SIZEOF_ZEND_LONG == 4
                        V_VT(v) = VT_I4;
                        V_I4(v) = Z_LVAL_P(z);
+#else
+                       V_VT(v) = VT_I8;
+                       V_I8(v) = Z_LVAL_P(z);
+#endif
                        break;
 
                case IS_DOUBLE:
@@ -159,9 +164,9 @@ PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codep
                        V_VT(v) = VT_BSTR;
                        olestring = php_com_string_to_olestring(Z_STRVAL_P(z), Z_STRLEN_P(z), codepage TSRMLS_CC);
                        if (CP_UTF8 == codepage) {
-                               V_BSTR(v) = SysAllocStringByteLen((char*)olestring, wcslen(olestring) * sizeof(OLECHAR));
+                               V_BSTR(v) = SysAllocStringByteLen((char*)olestring, (UINT)(wcslen(olestring) * sizeof(OLECHAR)));
                        } else {
-                               V_BSTR(v) = SysAllocStringByteLen((char*)olestring, Z_STRLEN_P(z) * sizeof(OLECHAR));
+                               V_BSTR(v) = SysAllocStringByteLen((char*)olestring, (UINT)(Z_STRLEN_P(z) * sizeof(OLECHAR)));
                        }
                        efree(olestring);
                        break;
@@ -428,7 +433,7 @@ PHP_FUNCTION(com_variant_create_instance)
 
        php_com_initialize(TSRMLS_C);
        if (ZEND_NUM_ARGS() == 3) {
-               obj->code_page = codepage;
+               obj->code_page = (int)codepage;
        }
 
        if (zvalue) {
@@ -849,7 +854,7 @@ PHP_FUNCTION(variant_round)
                return;
        }
 
-       if (SUCCEEDED(VarRound(vleft, decimals, &vres))) {
+       if (SUCCEEDED(VarRound(vleft, (int)decimals, &vres))) {
                php_com_wrap_variant(return_value, &vres, codepage TSRMLS_CC);
        }
 
@@ -909,7 +914,7 @@ PHP_FUNCTION(variant_cmp)
                return;
        }
 
-       ZVAL_LONG(return_value, VarCmp(vleft, vright, lcid, flags));
+       ZVAL_LONG(return_value, VarCmp(vleft, vright, (LCID)lcid, (ULONG)flags));
 
        VariantClear(&left_val);
        VariantClear(&right_val);
index 6112dfb4bfa85508ad72bfe53eea00c76201eda1..f7dd7fd4637a9c153b7a0baca7b2a1f26ce76041 100644 (file)
@@ -186,7 +186,7 @@ static HRESULT STDMETHODCALLTYPE disp_getidsofnames(
                        ret = DISP_E_UNKNOWNNAME;
                        rgDispId[i] = 0;
                } else {
-                       rgDispId[i] = Z_LVAL_P(tmp);
+                       rgDispId[i] = (DISPID)Z_LVAL_P(tmp);
                }
 
                efree(name);
@@ -231,7 +231,7 @@ static HRESULT STDMETHODCALLTYPE disp_getdispid(
        /* Lookup the name in the hash */
        if ((tmp = zend_hash_str_find(disp->name_to_dispid, name, namelen)) != NULL) {
                trace("found it\n");
-               *pid = Z_LVAL_P(tmp);
+               *pid = (DISPID)Z_LVAL_P(tmp);
                ret = S_OK;
        }
 
index e79e6f586da7d59fbb9ee607c70236e2bc71d8ee..e06f50c7d6c69a030b1b79a7c890b50c3626f181 100644 (file)
@@ -37,8 +37,9 @@ typedef struct _php_com_dotnet_object {
        VARIANT v;
        int modified;
 
+       int code_page;
+
        ITypeInfo *typeinfo;
-       zend_long code_page;
 
        zend_class_entry *ce;
 
@@ -107,7 +108,7 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
                size_t namelen, DISPID *dispid TSRMLS_DC);
 int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid,
                WORD flags,     VARIANT *v, int nargs, zval *args, int silent, int allow_noarg TSRMLS_DC);
-int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen,
+int php_com_do_invoke(php_com_dotnet_object *obj, char *name, size_t namelen,
                WORD flags,     VARIANT *v, int nargs, zval *args, int allow_noarg TSRMLS_DC);
 int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function *f,
                WORD flags,     VARIANT *v, int nargs, zval *args TSRMLS_DC);