mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
ffi: Use true / false instead of 1 / 0 for bool parameters
Changes done with Coccinelle:
@r1@
identifier F;
identifier p;
typedef bool;
parameter list [n1] PL1;
parameter list [n2] PL2;
@@
F(PL1, bool p, PL2) {
...
}
@r2@
identifier r1.F;
expression list [r1.n1] EL1;
expression list [r1.n2] EL2;
@@
F(EL1,
(
- 1
+ true
|
- 0
+ false
)
, EL2)
This commit is contained in:
committed by
Tim Düsterhus
parent
3e36598f8a
commit
3e30deda09
@@ -957,7 +957,8 @@ static void zend_ffi_callback_trampoline(ffi_cif* cif, void* ret, void** args, v
|
||||
|
||||
ZEND_HASH_PACKED_FOREACH_PTR(callback_data->type->func.args, arg_type) {
|
||||
arg_type = ZEND_FFI_TYPE(arg_type);
|
||||
zend_ffi_cdata_to_zval(NULL, args[n], arg_type, BP_VAR_R, &fci.params[n], (zend_ffi_flags)(arg_type->attr & ZEND_FFI_ATTR_CONST), 0, 0);
|
||||
zend_ffi_cdata_to_zval(NULL, args[n], arg_type, BP_VAR_R, &fci.params[n], (zend_ffi_flags)(arg_type->attr & ZEND_FFI_ATTR_CONST),
|
||||
false, false);
|
||||
n++;
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
}
|
||||
@@ -1133,7 +1134,7 @@ static zval *zend_ffi_cdata_get(zend_object *obj, zend_string *member, int read_
|
||||
return &EG(uninitialized_zval);
|
||||
}
|
||||
|
||||
zend_ffi_cdata_to_zval(cdata, cdata->ptr, type, BP_VAR_R, rv, 0, 0, 0);
|
||||
zend_ffi_cdata_to_zval(cdata, cdata->ptr, type, BP_VAR_R, rv, 0, false, false);
|
||||
return rv;
|
||||
}
|
||||
/* }}} */
|
||||
@@ -1302,7 +1303,8 @@ static zval *zend_ffi_cdata_read_field(zend_object *obj, zend_string *field_name
|
||||
}
|
||||
}
|
||||
ptr = (void*)(((char*)ptr) + field->offset);
|
||||
zend_ffi_cdata_to_zval(NULL, ptr, field_type, read_type, rv, (cdata->flags & ZEND_FFI_FLAG_CONST) | (zend_ffi_flags)field->is_const, 0, 0);
|
||||
zend_ffi_cdata_to_zval(NULL, ptr, field_type, read_type, rv, (cdata->flags & ZEND_FFI_FLAG_CONST) | (zend_ffi_flags)field->is_const,
|
||||
false, false);
|
||||
} else {
|
||||
zend_ffi_bit_field_to_zval(ptr, field, rv);
|
||||
}
|
||||
@@ -1438,7 +1440,7 @@ static zval *zend_ffi_cdata_read_dim(zend_object *obj, zval *offset, int read_ty
|
||||
return &EG(uninitialized_zval);
|
||||
}
|
||||
|
||||
zend_ffi_cdata_to_zval(NULL, ptr, dim_type, read_type, rv, is_const, 0, 0);
|
||||
zend_ffi_cdata_to_zval(NULL, ptr, dim_type, read_type, rv, is_const, false, false);
|
||||
return rv;
|
||||
}
|
||||
/* }}} */
|
||||
@@ -1984,7 +1986,8 @@ static zval *zend_ffi_cdata_it_get_current_data(zend_object_iterator *it) /* {{{
|
||||
ptr = (void*)((char*)cdata->ptr + dim_type->size * iter->it.index);
|
||||
|
||||
zval_ptr_dtor(&iter->value);
|
||||
zend_ffi_cdata_to_zval(NULL, ptr, dim_type, iter->by_ref ? BP_VAR_RW : BP_VAR_R, &iter->value, (cdata->flags & ZEND_FFI_FLAG_CONST) | (zend_ffi_flags)(type->attr & ZEND_FFI_ATTR_CONST), 0, 0);
|
||||
zend_ffi_cdata_to_zval(NULL, ptr, dim_type, iter->by_ref ? BP_VAR_RW : BP_VAR_R, &iter->value, (cdata->flags & ZEND_FFI_FLAG_CONST) | (zend_ffi_flags)(type->attr & ZEND_FFI_ATTR_CONST),
|
||||
false, false);
|
||||
return &iter->value;
|
||||
}
|
||||
/* }}} */
|
||||
@@ -2082,7 +2085,7 @@ static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp)
|
||||
case ZEND_FFI_TYPE_SINT32:
|
||||
case ZEND_FFI_TYPE_UINT64:
|
||||
case ZEND_FFI_TYPE_SINT64:
|
||||
zend_ffi_cdata_to_zval(cdata, ptr, type, BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, 0, 0);
|
||||
zend_ffi_cdata_to_zval(cdata, ptr, type, BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, false, false);
|
||||
ht = zend_new_array(1);
|
||||
zend_hash_str_add(ht, "cdata", sizeof("cdata")-1, &tmp);
|
||||
*is_temp = 1;
|
||||
@@ -2102,7 +2105,8 @@ static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp)
|
||||
*is_temp = 1;
|
||||
return ht;
|
||||
} else {
|
||||
zend_ffi_cdata_to_zval(NULL, *(void**)ptr, ZEND_FFI_TYPE(type->pointer.type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, 0, 0);
|
||||
zend_ffi_cdata_to_zval(NULL, *(void**)ptr, ZEND_FFI_TYPE(type->pointer.type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST,
|
||||
false, false);
|
||||
ht = zend_new_array(1);
|
||||
zend_hash_index_add_new(ht, 0, &tmp);
|
||||
*is_temp = 1;
|
||||
@@ -2115,7 +2119,8 @@ static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp)
|
||||
if (key) {
|
||||
if (!f->bits) {
|
||||
void *f_ptr = (void*)(((char*)ptr) + f->offset);
|
||||
zend_ffi_cdata_to_zval(NULL, f_ptr, ZEND_FFI_TYPE(f->type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, 0, type->attr & ZEND_FFI_ATTR_UNION);
|
||||
zend_ffi_cdata_to_zval(NULL, f_ptr, ZEND_FFI_TYPE(f->type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST,
|
||||
false, type->attr & ZEND_FFI_ATTR_UNION);
|
||||
zend_hash_add(ht, key, &tmp);
|
||||
} else {
|
||||
zend_ffi_bit_field_to_zval(ptr, f, &tmp);
|
||||
@@ -2128,7 +2133,8 @@ static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp)
|
||||
case ZEND_FFI_TYPE_ARRAY:
|
||||
ht = zend_new_array(type->array.length);
|
||||
for (n = 0; n < type->array.length; n++) {
|
||||
zend_ffi_cdata_to_zval(NULL, ptr, ZEND_FFI_TYPE(type->array.type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, 0, 0);
|
||||
zend_ffi_cdata_to_zval(NULL, ptr, ZEND_FFI_TYPE(type->array.type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST,
|
||||
false, false);
|
||||
zend_hash_index_add(ht, n, &tmp);
|
||||
ptr = (void*)(((char*)ptr) + ZEND_FFI_TYPE(type->array.type)->size);
|
||||
}
|
||||
@@ -2509,7 +2515,8 @@ static zval *zend_ffi_read_var(zend_object *obj, zend_string *var_name, int read
|
||||
}
|
||||
|
||||
if (sym->kind == ZEND_FFI_SYM_VAR) {
|
||||
zend_ffi_cdata_to_zval(NULL, sym->addr, ZEND_FFI_TYPE(sym->type), read_type, rv, (zend_ffi_flags)sym->is_const, 0, 0);
|
||||
zend_ffi_cdata_to_zval(NULL, sym->addr, ZEND_FFI_TYPE(sym->type), read_type, rv, (zend_ffi_flags)sym->is_const,
|
||||
false, false);
|
||||
} else if (sym->kind == ZEND_FFI_SYM_FUNC) {
|
||||
zend_ffi_cdata *cdata;
|
||||
zend_ffi_type *new_type = emalloc(sizeof(zend_ffi_type));
|
||||
@@ -3764,14 +3771,14 @@ static zend_result zend_ffi_validate_var_type(const zend_ffi_type *type, bool al
|
||||
zend_ffi_throw_parser_error("function type is not allowed at line %d", FFI_G(line));
|
||||
return FAILURE;
|
||||
}
|
||||
return zend_ffi_validate_type(type, 0, allow_incomplete_array);
|
||||
return zend_ffi_validate_type(type, false, allow_incomplete_array);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void zend_ffi_validate_type_name(zend_ffi_dcl *dcl) /* {{{ */
|
||||
{
|
||||
zend_ffi_finalize_type(dcl);
|
||||
if (zend_ffi_validate_var_type(ZEND_FFI_TYPE(dcl->type), 0) == FAILURE) {
|
||||
if (zend_ffi_validate_var_type(ZEND_FFI_TYPE(dcl->type), false) == FAILURE) {
|
||||
zend_ffi_cleanup_dcl(dcl);
|
||||
LONGJMP(FFI_G(bailout), FAILURE);
|
||||
}
|
||||
@@ -5369,7 +5376,7 @@ static zend_result zend_ffi_preload_glob(const char *filename) /* {{{ */
|
||||
/* pass */
|
||||
} else {
|
||||
for(i=0 ; i<globbuf.gl_pathc; i++) {
|
||||
zend_ffi *ffi = zend_ffi_load(globbuf.gl_pathv[i], 1);
|
||||
zend_ffi *ffi = zend_ffi_load(globbuf.gl_pathv[i], true);
|
||||
if (!ffi) {
|
||||
php_globfree(&globbuf);
|
||||
return FAILURE;
|
||||
@@ -5397,7 +5404,7 @@ static zend_result zend_ffi_preload(char *preload) /* {{{ */
|
||||
filename = estrndup(s, e-s);
|
||||
s = NULL;
|
||||
if (!is_glob) {
|
||||
ffi = zend_ffi_load(filename, 1);
|
||||
ffi = zend_ffi_load(filename, true);
|
||||
efree(filename);
|
||||
if (!ffi) {
|
||||
return FAILURE;
|
||||
@@ -5430,7 +5437,7 @@ static zend_result zend_ffi_preload(char *preload) /* {{{ */
|
||||
if (s) {
|
||||
filename = estrndup(s, e-s);
|
||||
if (!is_glob) {
|
||||
ffi = zend_ffi_load(filename, 1);
|
||||
ffi = zend_ffi_load(filename, true);
|
||||
efree(filename);
|
||||
if (!ffi) {
|
||||
return FAILURE;
|
||||
@@ -6142,7 +6149,7 @@ static zend_result zend_ffi_validate_field_type(const zend_ffi_type *type, zend_
|
||||
if (type == struct_type) {
|
||||
zend_ffi_throw_parser_error("Struct/union can't contain an instance of itself at line %d", FFI_G(line));
|
||||
return FAILURE;
|
||||
} else if (zend_ffi_validate_var_type(type, 1) == FAILURE) {
|
||||
} else if (zend_ffi_validate_var_type(type, true) == FAILURE) {
|
||||
return FAILURE;
|
||||
} else if (struct_type->attr & ZEND_FFI_ATTR_UNION) {
|
||||
if (type->attr & ZEND_FFI_ATTR_INCOMPLETE_ARRAY) {
|
||||
@@ -6412,7 +6419,7 @@ static zend_result zend_ffi_validate_array_element_type(const zend_ffi_type *typ
|
||||
zend_ffi_throw_parser_error("Only the leftmost array can be undimensioned at line %d", FFI_G(line));
|
||||
return FAILURE;
|
||||
}
|
||||
return zend_ffi_validate_type(type, 0, 1);
|
||||
return zend_ffi_validate_type(type, false, true);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -6472,7 +6479,7 @@ static zend_result zend_ffi_validate_func_ret_type(const zend_ffi_type *type) /*
|
||||
zend_ffi_throw_parser_error("Function returning array is not allowed at line %d", FFI_G(line));
|
||||
return FAILURE;
|
||||
}
|
||||
return zend_ffi_validate_incomplete_type(type, 1, 0);
|
||||
return zend_ffi_validate_incomplete_type(type, true, false);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -6646,7 +6653,7 @@ void zend_ffi_add_arg(HashTable **args, const char *name, size_t name_len, zend_
|
||||
new_type->pointer.type = arg_dcl->type;
|
||||
arg_dcl->type = ZEND_FFI_TYPE_MAKE_OWNED(new_type);
|
||||
}
|
||||
if (zend_ffi_validate_incomplete_type(type, 1, 1) == FAILURE) {
|
||||
if (zend_ffi_validate_incomplete_type(type, true, true) == FAILURE) {
|
||||
zend_ffi_cleanup_dcl(arg_dcl);
|
||||
zend_hash_destroy(*args);
|
||||
pefree(*args, FFI_G(persistent));
|
||||
@@ -6725,7 +6732,7 @@ void zend_ffi_declare(const char *name, size_t name_len, zend_ffi_dcl *dcl) /* {
|
||||
zend_ffi_type *type;
|
||||
|
||||
type = ZEND_FFI_TYPE(dcl->type);
|
||||
if (zend_ffi_validate_type(type, (dcl->flags & ZEND_FFI_DCL_STORAGE_CLASS) == ZEND_FFI_DCL_EXTERN, 1) == FAILURE) {
|
||||
if (zend_ffi_validate_type(type, (dcl->flags & ZEND_FFI_DCL_STORAGE_CLASS) == ZEND_FFI_DCL_EXTERN, true) == FAILURE) {
|
||||
zend_ffi_cleanup_dcl(dcl);
|
||||
LONGJMP(FFI_G(bailout), FAILURE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user