Skip to content

Commit 41a505f

Browse files
committed
fix datatype mismatches
1 parent e4464a8 commit 41a505f

File tree

9 files changed

+40
-34
lines changed

9 files changed

+40
-34
lines changed

ext/com_dotnet/com_com.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,19 @@ PHP_FUNCTION(com_create_instance)
129129

130130
if (user_name) {
131131
authid.User = php_com_string_to_olestring(user_name, -1, obj->code_page TSRMLS_CC);
132-
authid.UserLength = user_name_len;
132+
authid.UserLength = (ULONG)user_name_len;
133133

134134
if (password) {
135135
authid.Password = (OLECHAR*)password;
136-
authid.PasswordLength = password_len;
136+
authid.PasswordLength = (ULONG)password_len;
137137
} else {
138138
authid.Password = (OLECHAR*)"";
139139
authid.PasswordLength = 0;
140140
}
141141

142142
if (domain_name) {
143143
authid.Domain = (OLECHAR*)domain_name;
144-
authid.DomainLength = domain_name_len;
144+
authid.DomainLength = (ULONG)domain_name_len;
145145
} else {
146146
authid.Domain = (OLECHAR*)"";
147147
authid.DomainLength = 0;
@@ -288,7 +288,7 @@ PHP_FUNCTION(com_get_active_object)
288288
{
289289
CLSID clsid;
290290
char *module_name;
291-
int module_name_len;
291+
size_t module_name_len;
292292
zend_long code_page = COMG(code_page);
293293
IUnknown *unk = NULL;
294294
IDispatch *obj = NULL;
@@ -302,7 +302,7 @@ PHP_FUNCTION(com_get_active_object)
302302
return;
303303
}
304304

305-
module = php_com_string_to_olestring(module_name, module_name_len, code_page TSRMLS_CC);
305+
module = php_com_string_to_olestring(module_name, module_name_len, (int)code_page TSRMLS_CC);
306306

307307
res = CLSIDFromString(module, &clsid);
308308

@@ -320,7 +320,7 @@ PHP_FUNCTION(com_get_active_object)
320320
php_com_throw_exception(res, NULL TSRMLS_CC);
321321
} else if (obj) {
322322
/* we got our dispatchable object */
323-
php_com_wrap_dispatch(return_value, obj, code_page TSRMLS_CC);
323+
php_com_wrap_dispatch(return_value, obj, (int)code_page TSRMLS_CC);
324324
}
325325
}
326326
}
@@ -427,7 +427,7 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
427427
}
428428

429429
if (obj->id_of_name_cache && NULL != (tmp = zend_hash_str_find(obj->id_of_name_cache, name, namelen))) {
430-
*dispid = Z_LVAL_P(tmp);
430+
*dispid = (DISPID)Z_LVAL_P(tmp);
431431
return S_OK;
432432
}
433433

@@ -631,7 +631,7 @@ int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid,
631631
return SUCCEEDED(hr) ? SUCCESS : FAILURE;
632632
}
633633

634-
int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen,
634+
int php_com_do_invoke(php_com_dotnet_object *obj, char *name, size_t namelen,
635635
WORD flags, VARIANT *v, int nargs, zval *args, int allow_noarg TSRMLS_DC)
636636
{
637637
DISPID dispid;
@@ -791,7 +791,7 @@ PHP_FUNCTION(com_message_pump)
791791
RETURN_FALSE;
792792

793793
php_com_initialize(TSRMLS_C);
794-
result = MsgWaitForMultipleObjects(0, NULL, FALSE, timeoutms, QS_ALLINPUT);
794+
result = MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD)timeoutms, QS_ALLINPUT);
795795

796796
if (result == WAIT_OBJECT_0) {
797797
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {

ext/com_dotnet/com_handlers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static zval *com_read_dimension(zval *object, zval *offset, int type, zval *rv T
101101
convert_to_long(offset);
102102

103103
if (SafeArrayGetDim(V_ARRAY(&obj->v)) == 1) {
104-
if (php_com_safearray_get_elem(&obj->v, &v, Z_LVAL_P(offset) TSRMLS_CC)) {
104+
if (php_com_safearray_get_elem(&obj->v, &v, (LONG)Z_LVAL_P(offset) TSRMLS_CC)) {
105105
php_com_wrap_variant(rv, &v, obj->code_page TSRMLS_CC);
106106
VariantClear(&v);
107107
}
@@ -145,7 +145,7 @@ static void com_write_dimension(zval *object, zval *offset, zval *value TSRMLS_D
145145
}
146146

147147
convert_to_long(offset);
148-
indices = Z_LVAL_P(offset);
148+
indices = (LONG)Z_LVAL_P(offset);
149149

150150
VariantInit(&v);
151151
php_com_variant_from_zval(&v, value, obj->code_page TSRMLS_CC);

ext/com_dotnet/com_olechar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, size_t str
4949
/* XXX if that's a real multibyte string, olestring is obviously allocated excessively.
5050
This should be fixed by reallocating the olestring, but as emalloc is used, that doesn't
5151
matter much. */
52-
ok = MultiByteToWideChar(codepage, flags, string, string_len, olestring, string_len);
52+
ok = MultiByteToWideChar(codepage, flags, string, (int)string_len, olestring, (int)string_len);
5353
if (ok > 0 && ok < string_len) {
5454
olestring[ok] = '\0';
5555
}

ext/com_dotnet/com_persist.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ static ULONG STDMETHODCALLTYPE stm_release(IStream *This)
105105

106106
static HRESULT STDMETHODCALLTYPE stm_read(IStream *This, void *pv, ULONG cb, ULONG *pcbRead)
107107
{
108-
int nread;
108+
ULONG nread;
109109
FETCH_STM();
110110

111-
nread = php_stream_read(stm->stream, pv, cb);
111+
nread = (ULONG)php_stream_read(stm->stream, pv, cb);
112112

113113
if (pcbRead) {
114114
*pcbRead = nread > 0 ? nread : 0;
@@ -121,10 +121,10 @@ static HRESULT STDMETHODCALLTYPE stm_read(IStream *This, void *pv, ULONG cb, ULO
121121

122122
static HRESULT STDMETHODCALLTYPE stm_write(IStream *This, void const *pv, ULONG cb, ULONG *pcbWritten)
123123
{
124-
int nwrote;
124+
ULONG nwrote;
125125
FETCH_STM();
126126

127-
nwrote = php_stream_write(stm->stream, pv, cb);
127+
nwrote = (ULONG)php_stream_write(stm->stream, pv, cb);
128128

129129
if (pcbWritten) {
130130
*pcbWritten = nwrote > 0 ? nwrote : 0;
@@ -466,7 +466,7 @@ CPH_METHOD(LoadFromFile)
466466
olefilename = php_com_string_to_olestring(fullpath, strlen(fullpath), helper->codepage TSRMLS_CC);
467467
efree(fullpath);
468468

469-
res = IPersistFile_Load(helper->ipf, olefilename, flags);
469+
res = IPersistFile_Load(helper->ipf, olefilename, (DWORD)flags);
470470
efree(olefilename);
471471

472472
if (FAILED(res)) {

ext/com_dotnet/com_saproxy.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval *
167167
/* copy indices from proxy */
168168
for (i = 0; i < dims; i++) {
169169
convert_to_long(&proxy->indices[i]);
170-
indices[i] = Z_LVAL(proxy->indices[i]);
170+
indices[i] = (LONG)Z_LVAL(proxy->indices[i]);
171171
}
172172

173173
/* add user-supplied index */
174-
indices[dims-1] = Z_LVAL_P(offset);
174+
indices[dims-1] = (LONG)Z_LVAL_P(offset);
175175

176176
/* now fetch the value */
177177
if (FAILED(SafeArrayGetVartype(sa, &vt)) || vt == VT_EMPTY) {
@@ -241,12 +241,12 @@ static void saproxy_write_dimension(zval *object, zval *offset, zval *value TSRM
241241
/* copy indices from proxy */
242242
for (i = 0; i < dims; i++) {
243243
convert_to_long(&proxy->indices[i]);
244-
indices[i] = Z_LVAL(proxy->indices[i]);
244+
indices[i] = (LONG)Z_LVAL(proxy->indices[i]);
245245
}
246246

247247
/* add user-supplied index */
248248
convert_to_long(offset);
249-
indices[dims-1] = Z_LVAL_P(offset);
249+
indices[dims-1] = (LONG)Z_LVAL_P(offset);
250250

251251
if (FAILED(SafeArrayGetVartype(V_ARRAY(&proxy->obj->v), &vt)) || vt == VT_EMPTY) {
252252
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
555555
I->indices = safe_emalloc(proxy->dimensions + 1, sizeof(LONG), 0);
556556
for (i = 0; i < proxy->dimensions; i++) {
557557
convert_to_long(&proxy->indices[i]);
558-
I->indices[i] = Z_LVAL(proxy->indices[i]);
558+
I->indices[i] = (LONG)Z_LVAL(proxy->indices[i]);
559559
}
560560

561561
SafeArrayGetLBound(V_ARRAY(&proxy->obj->v), proxy->dimensions, &I->imin);

ext/com_dotnet/com_typeinfo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep
116116
continue;
117117
}
118118
/* get the default value for this key and compare */
119-
libnamelen = strlen(search_string)+1;
119+
libnamelen = (DWORD)strlen(search_string)+1;
120120
if (ERROR_SUCCESS == RegQueryValue(hsubkey, version, libname, &libnamelen)) {
121121
if (0 == stricmp(libname, search_string)) {
122122
char *str = NULL;
@@ -234,7 +234,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string,
234234
{
235235
ITypeLib *TL;
236236
char *name_dup;
237-
int l;
237+
size_t l;
238238

239239
l = strlen(search_string);
240240

ext/com_dotnet/com_variant.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC)
6262

6363
/* allocate the structure */
6464
bound.lLbound = 0;
65-
bound.cElements = intindex + 1;
65+
bound.cElements = (ULONG)(intindex + 1);
6666
sa = SafeArrayCreate(VT_VARIANT, 1, &bound);
6767

6868
/* 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
146146
break;
147147

148148
case IS_LONG:
149+
#if SIZEOF_ZEND_LONG == 4
149150
V_VT(v) = VT_I4;
150151
V_I4(v) = Z_LVAL_P(z);
152+
#else
153+
V_VT(v) = VT_I8;
154+
V_I8(v) = Z_LVAL_P(z);
155+
#endif
151156
break;
152157

153158
case IS_DOUBLE:
@@ -159,9 +164,9 @@ PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codep
159164
V_VT(v) = VT_BSTR;
160165
olestring = php_com_string_to_olestring(Z_STRVAL_P(z), Z_STRLEN_P(z), codepage TSRMLS_CC);
161166
if (CP_UTF8 == codepage) {
162-
V_BSTR(v) = SysAllocStringByteLen((char*)olestring, wcslen(olestring) * sizeof(OLECHAR));
167+
V_BSTR(v) = SysAllocStringByteLen((char*)olestring, (UINT)(wcslen(olestring) * sizeof(OLECHAR)));
163168
} else {
164-
V_BSTR(v) = SysAllocStringByteLen((char*)olestring, Z_STRLEN_P(z) * sizeof(OLECHAR));
169+
V_BSTR(v) = SysAllocStringByteLen((char*)olestring, (UINT)(Z_STRLEN_P(z) * sizeof(OLECHAR)));
165170
}
166171
efree(olestring);
167172
break;
@@ -428,7 +433,7 @@ PHP_FUNCTION(com_variant_create_instance)
428433

429434
php_com_initialize(TSRMLS_C);
430435
if (ZEND_NUM_ARGS() == 3) {
431-
obj->code_page = codepage;
436+
obj->code_page = (int)codepage;
432437
}
433438

434439
if (zvalue) {
@@ -849,7 +854,7 @@ PHP_FUNCTION(variant_round)
849854
return;
850855
}
851856

852-
if (SUCCEEDED(VarRound(vleft, decimals, &vres))) {
857+
if (SUCCEEDED(VarRound(vleft, (int)decimals, &vres))) {
853858
php_com_wrap_variant(return_value, &vres, codepage TSRMLS_CC);
854859
}
855860

@@ -909,7 +914,7 @@ PHP_FUNCTION(variant_cmp)
909914
return;
910915
}
911916

912-
ZVAL_LONG(return_value, VarCmp(vleft, vright, lcid, flags));
917+
ZVAL_LONG(return_value, VarCmp(vleft, vright, (LCID)lcid, (ULONG)flags));
913918

914919
VariantClear(&left_val);
915920
VariantClear(&right_val);

ext/com_dotnet/com_wrapper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static HRESULT STDMETHODCALLTYPE disp_getidsofnames(
186186
ret = DISP_E_UNKNOWNNAME;
187187
rgDispId[i] = 0;
188188
} else {
189-
rgDispId[i] = Z_LVAL_P(tmp);
189+
rgDispId[i] = (DISPID)Z_LVAL_P(tmp);
190190
}
191191

192192
efree(name);
@@ -231,7 +231,7 @@ static HRESULT STDMETHODCALLTYPE disp_getdispid(
231231
/* Lookup the name in the hash */
232232
if ((tmp = zend_hash_str_find(disp->name_to_dispid, name, namelen)) != NULL) {
233233
trace("found it\n");
234-
*pid = Z_LVAL_P(tmp);
234+
*pid = (DISPID)Z_LVAL_P(tmp);
235235
ret = S_OK;
236236
}
237237

ext/com_dotnet/php_com_dotnet_internal.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ typedef struct _php_com_dotnet_object {
3737
VARIANT v;
3838
int modified;
3939

40+
int code_page;
41+
4042
ITypeInfo *typeinfo;
41-
zend_long code_page;
4243

4344
zend_class_entry *ce;
4445

@@ -107,7 +108,7 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
107108
size_t namelen, DISPID *dispid TSRMLS_DC);
108109
int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid,
109110
WORD flags, VARIANT *v, int nargs, zval *args, int silent, int allow_noarg TSRMLS_DC);
110-
int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen,
111+
int php_com_do_invoke(php_com_dotnet_object *obj, char *name, size_t namelen,
111112
WORD flags, VARIANT *v, int nargs, zval *args, int allow_noarg TSRMLS_DC);
112113
int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function *f,
113114
WORD flags, VARIANT *v, int nargs, zval *args TSRMLS_DC);

0 commit comments

Comments
 (0)