Skip to content

Commit 271081d

Browse files
committed
ext/ffi: add casts to work around -Wassign-enum
1 parent 2540210 commit 271081d

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

ext/ffi/ffi.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static zend_object *zend_ffi_cdata_new(zend_class_entry *class_type) /* {{{ */
261261

262262
cdata->type = NULL;
263263
cdata->ptr = NULL;
264-
cdata->flags = 0;
264+
cdata->flags = (zend_ffi_flags)0;
265265

266266
return &cdata->std;
267267
}
@@ -1110,7 +1110,7 @@ static zval *zend_ffi_cdata_get(zend_object *obj, zend_string *member, int read_
11101110
return &EG(uninitialized_zval);
11111111
}
11121112

1113-
zend_ffi_cdata_to_zval(cdata, cdata->ptr, type, BP_VAR_R, rv, 0, 0, 0);
1113+
zend_ffi_cdata_to_zval(cdata, cdata->ptr, type, BP_VAR_R, rv, (zend_ffi_flags)0, 0, 0);
11141114
return rv;
11151115
}
11161116
/* }}} */
@@ -2833,7 +2833,7 @@ static ZEND_FUNCTION(ffi_trampoline) /* {{{ */
28332833
}
28342834

28352835
if (ZEND_FFI_TYPE(type->func.ret_type)->kind != ZEND_FFI_TYPE_VOID) {
2836-
zend_ffi_cdata_to_zval(NULL, ret, ZEND_FFI_TYPE(type->func.ret_type), BP_VAR_R, return_value, 0, 1, 0);
2836+
zend_ffi_cdata_to_zval(NULL, ret, ZEND_FFI_TYPE(type->func.ret_type), BP_VAR_R, return_value, (zend_ffi_flags)0, 1, 0);
28372837
} else {
28382838
ZVAL_NULL(return_value);
28392839
}
@@ -3736,7 +3736,6 @@ ZEND_METHOD(FFI, new) /* {{{ */
37363736
bool owned = 1;
37373737
bool persistent = 0;
37383738
bool is_const = 0;
3739-
zend_ffi_flags flags = ZEND_FFI_FLAG_OWNED;
37403739

37413740
ZEND_FFI_VALIDATE_API_RESTRICTION();
37423741
ZEND_PARSE_PARAMETERS_START(1, 3)
@@ -3746,9 +3745,7 @@ ZEND_METHOD(FFI, new) /* {{{ */
37463745
Z_PARAM_BOOL(persistent)
37473746
ZEND_PARSE_PARAMETERS_END();
37483747

3749-
if (!owned) {
3750-
flags &= ~ZEND_FFI_FLAG_OWNED;
3751-
}
3748+
zend_ffi_flags flags = owned ? ZEND_FFI_FLAG_OWNED : 0;
37523749

37533750
if (persistent) {
37543751
flags |= ZEND_FFI_FLAG_PERSISTENT;
@@ -3871,7 +3868,7 @@ ZEND_METHOD(FFI, free) /* {{{ */
38713868
} else if (!(cdata->flags & ZEND_FFI_FLAG_OWNED)) {
38723869
pefree(cdata->ptr, cdata->flags & ZEND_FFI_FLAG_PERSISTENT);
38733870
cdata->ptr = NULL;
3874-
cdata->flags &= ~(ZEND_FFI_FLAG_OWNED|ZEND_FFI_FLAG_PERSISTENT);
3871+
cdata->flags = (zend_ffi_flags)(cdata->flags & ~(ZEND_FFI_FLAG_OWNED|ZEND_FFI_FLAG_PERSISTENT));
38753872
cdata->std.handlers = &zend_ffi_cdata_free_handlers;
38763873
} else {
38773874
zend_throw_error(zend_ffi_exception_ce, "free() non a C pointer");
@@ -4045,7 +4042,7 @@ ZEND_METHOD(FFI, cast) /* {{{ */
40454042
if (old_cdata->flags & ZEND_FFI_FLAG_OWNED) {
40464043
if (GC_REFCOUNT(&old_cdata->std) == 1 && Z_REFCOUNT_P(arg) == 1) {
40474044
/* transfer ownership */
4048-
old_cdata->flags &= ~ZEND_FFI_FLAG_OWNED;
4045+
old_cdata->flags = (zend_ffi_flags)(old_cdata->flags & ~ZEND_FFI_FLAG_OWNED);
40494046
cdata->flags |= ZEND_FFI_FLAG_OWNED;
40504047
} else {
40514048
//???zend_throw_error(zend_ffi_exception_ce, "Attempt to cast owned C pointer");
@@ -4282,7 +4279,7 @@ ZEND_METHOD(FFI, addr) /* {{{ */
42824279
}
42834280
if (cdata->flags & ZEND_FFI_FLAG_OWNED) {
42844281
/* transfer ownership */
4285-
cdata->flags &= ~ZEND_FFI_FLAG_OWNED;
4282+
cdata->flags = (zend_ffi_flags)(cdata->flags & ~ZEND_FFI_FLAG_OWNED);
42864283
new_cdata->flags |= ZEND_FFI_FLAG_OWNED;
42874284
}
42884285
}

0 commit comments

Comments
 (0)