Various return types and values consolidation (#19418)

This commit is contained in:
Alexandre Daubois 2025-08-12 12:28:41 +02:00 committed by GitHub
parent 3dc962b9f7
commit dfa1307a64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 32 additions and 36 deletions

View file

@ -3770,7 +3770,7 @@ static zend_always_inline zend_class_entry *get_scope(zend_execute_data *frame)
static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *scope, zend_execute_data *frame, zend_fcall_info_cache *fcc, bool *strict_class, char **error, bool suppress_deprecation) /* {{{ */
{
bool ret = 0;
bool ret = false;
zend_class_entry *ce;
size_t name_len = ZSTR_LEN(name);
zend_string *lcname;
@ -3795,7 +3795,7 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc
if (!fcc->object) {
fcc->object = zend_get_this_object(frame);
}
ret = 1;
ret = true;
}
} else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_PARENT))) {
if (!scope) {
@ -3815,7 +3815,7 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc
fcc->object = zend_get_this_object(frame);
}
*strict_class = 1;
ret = 1;
ret = true;
}
} else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_STATIC))) {
zend_class_entry *called_scope = zend_get_called_scope(frame);
@ -3832,7 +3832,7 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc
fcc->object = zend_get_this_object(frame);
}
*strict_class = 1;
ret = 1;
ret = true;
}
} else if ((ce = zend_lookup_class(name)) != NULL) {
zend_class_entry *scope = get_scope(frame);
@ -3852,7 +3852,7 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc
fcc->called_scope = fcc->object ? fcc->object->ce : ce;
}
*strict_class = 1;
ret = 1;
ret = true;
} else {
if (error) zend_spprintf(error, 0, "class \"%.*s\" not found", (int)name_len, ZSTR_VAL(name));
}

View file

@ -1198,7 +1198,7 @@ static struct php_gfxinfo *php_handle_avif(php_stream * stream) {
}
/* }}} */
/* {{{ php_is_image_avif
/*
* Detect whether an image is of type AVIF
*
* Only the first "ftyp" box is read.
@ -1208,12 +1208,8 @@ bool php_is_image_avif(php_stream* stream) {
struct php_avif_stream avif_stream;
avif_stream.stream = stream;
if (AvifInfoIdentifyStream(&avif_stream, php_avif_stream_read, php_avif_stream_skip) == kAvifInfoOk) {
return 1;
}
return 0;
return AvifInfoIdentifyStream(&avif_stream, php_avif_stream_read, php_avif_stream_skip) == kAvifInfoOk;
}
/* }}} */
/* {{{ php_image_type_to_mime_type
* Convert internal image_type to mime type */

View file

@ -346,7 +346,7 @@ static bool add_post_var(zval *arr, post_var_data_t *var, bool eof)
size_t new_vlen;
if (var->ptr >= var->end) {
return 0;
return false;
}
start = var->ptr + var->already_scanned;
@ -354,7 +354,7 @@ static bool add_post_var(zval *arr, post_var_data_t *var, bool eof)
if (!vsep) {
if (!eof) {
var->already_scanned = var->end - var->ptr;
return 0;
return false;
} else {
vsep = var->end;
}
@ -387,10 +387,10 @@ static bool add_post_var(zval *arr, post_var_data_t *var, bool eof)
var->ptr = vsep + (vsep != var->end);
var->already_scanned = 0;
return 1;
return true;
}
static inline int add_post_vars(zval *arr, post_var_data_t *vars, bool eof)
static inline zend_result add_post_vars(zval *arr, post_var_data_t *vars, bool eof)
{
uint64_t max_vars = REQUEST_PARSE_BODY_OPTION_GET(max_input_vars, PG(max_input_vars));
@ -782,7 +782,7 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src)
/* }}} */
/* {{{ php_hash_environment */
PHPAPI int php_hash_environment(void)
PHPAPI zend_result php_hash_environment(void)
{
memset(PG(http_globals), 0, sizeof(PG(http_globals)));
zend_activate_auto_globals();
@ -805,7 +805,7 @@ static bool php_auto_globals_create_get(zend_string *name)
zend_hash_update(&EG(symbol_table), name, &PG(http_globals)[TRACK_VARS_GET]);
Z_ADDREF(PG(http_globals)[TRACK_VARS_GET]);
return 0; /* don't rearm */
return false; /* don't rearm */
}
static bool php_auto_globals_create_post(zend_string *name)
@ -824,7 +824,7 @@ static bool php_auto_globals_create_post(zend_string *name)
zend_hash_update(&EG(symbol_table), name, &PG(http_globals)[TRACK_VARS_POST]);
Z_ADDREF(PG(http_globals)[TRACK_VARS_POST]);
return 0; /* don't rearm */
return false; /* don't rearm */
}
static bool php_auto_globals_create_cookie(zend_string *name)
@ -839,7 +839,7 @@ static bool php_auto_globals_create_cookie(zend_string *name)
zend_hash_update(&EG(symbol_table), name, &PG(http_globals)[TRACK_VARS_COOKIE]);
Z_ADDREF(PG(http_globals)[TRACK_VARS_COOKIE]);
return 0; /* don't rearm */
return false; /* don't rearm */
}
static bool php_auto_globals_create_files(zend_string *name)
@ -851,7 +851,7 @@ static bool php_auto_globals_create_files(zend_string *name)
zend_hash_update(&EG(symbol_table), name, &PG(http_globals)[TRACK_VARS_FILES]);
Z_ADDREF(PG(http_globals)[TRACK_VARS_FILES]);
return 0; /* don't rearm */
return false; /* don't rearm */
}
/* Ugly hack to fix HTTP_PROXY issue, see bug #72573 */
@ -905,7 +905,7 @@ static bool php_auto_globals_create_server(zend_string *name)
* ignore this issue, as it would probably require larger changes. */
HT_ALLOW_COW_VIOLATION(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]));
return 0; /* don't rearm */
return false; /* don't rearm */
}
static bool php_auto_globals_create_env(zend_string *name)
@ -921,7 +921,7 @@ static bool php_auto_globals_create_env(zend_string *name)
zend_hash_update(&EG(symbol_table), name, &PG(http_globals)[TRACK_VARS_ENV]);
Z_ADDREF(PG(http_globals)[TRACK_VARS_ENV]);
return 0; /* don't rearm */
return false; /* don't rearm */
}
static bool php_auto_globals_create_request(zend_string *name)
@ -965,7 +965,7 @@ static bool php_auto_globals_create_request(zend_string *name)
}
zend_hash_update(&EG(symbol_table), name, &form_variables);
return 0;
return false;
}
void php_startup_auto_globals(void)

View file

@ -39,7 +39,7 @@ PHPAPI void php_register_variable_ex(const char *var, zval *val, zval *track_var
PHPAPI void php_register_known_variable(const char *var, size_t var_len, zval *value, zval *track_vars_array);
PHPAPI void php_build_argv(const char *s, zval *track_vars_array);
PHPAPI int php_hash_environment(void);
PHPAPI zend_result php_hash_environment(void);
END_EXTERN_C()
#define NUM_TRACK_VARS 6

View file

@ -139,7 +139,7 @@ bool phpdbg_check_watch_diff(phpdbg_watchtype type, void *oldPtr, void *newPtr)
switch (type) {
case WATCH_ON_BUCKET:
if (memcmp(&((Bucket *) oldPtr)->h, &((Bucket *) newPtr)->h, sizeof(Bucket) - sizeof(zval) /* hash+key comparison */) != 0) {
return 2;
return true;
}
/* Fall through to also compare the value from the bucket. */
ZEND_FALLTHROUGH;
@ -154,7 +154,7 @@ bool phpdbg_check_watch_diff(phpdbg_watchtype type, void *oldPtr, void *newPtr)
case WATCH_ON_HASHDATA:
ZEND_UNREACHABLE();
}
return 0;
return false;
}
void phpdbg_print_watch_diff(phpdbg_watchtype type, zend_string *name, void *oldPtr, void *newPtr) {
@ -280,9 +280,9 @@ static inline void phpdbg_deactivate_watchpoint(phpdbg_watchpoint_t *watch) {
/* Note that consecutive pages need to be merged in order to avoid watchpoints spanning page boundaries to have part of their data in the one page, part in the other page */
#ifdef _WIN32
int phpdbg_watchpoint_segfault_handler(void *addr) {
zend_result phpdbg_watchpoint_segfault_handler(void *addr) {
#else
int phpdbg_watchpoint_segfault_handler(siginfo_t *info, void *context) {
zend_result phpdbg_watchpoint_segfault_handler(siginfo_t *info, void *context) {
#endif
void *page = phpdbg_get_page_boundary(
@ -562,12 +562,12 @@ bool phpdbg_is_recursively_watched(void *ptr, phpdbg_watch_element *element) {
do {
element = next;
if (element->watch->addr.ptr == ptr) {
return 1;
return true;
}
next = element->parent;
} while (!(element->flags & PHPDBG_WATCH_RECURSIVE_ROOT));
return 0;
return false;
}
void phpdbg_add_recursive_watch_from_ht(phpdbg_watch_element *element, zend_long idx, zend_string *str, zval *zv) {
@ -721,7 +721,7 @@ bool phpdbg_try_re_adding_watch_element(zval *parent, phpdbg_watch_element *elem
HashTable *ht = HT_FROM_ZVP(parent);
if (!ht) {
return 0;
return false;
} else if (element->flags & (PHPDBG_WATCH_ARRAY | PHPDBG_WATCH_OBJECT)) {
char *htPtr = ((char *) ht) + HT_WATCH_OFFSET;
char *oldPtr = ((char *) &element->backup.ht) + HT_WATCH_OFFSET;
@ -742,7 +742,7 @@ bool phpdbg_try_re_adding_watch_element(zval *parent, phpdbg_watch_element *elem
}
if (!phpdbg_try_re_adding_watch_element(next, element->child)) {
return 0;
return false;
}
} else if (phpdbg_check_watch_diff(WATCH_ON_ZVAL, &element->backup.zv, zv)) {
phpdbg_print_watch_diff(WATCH_ON_ZVAL, element->str, &element->backup.zv, zv);
@ -752,10 +752,10 @@ bool phpdbg_try_re_adding_watch_element(zval *parent, phpdbg_watch_element *elem
phpdbg_add_bucket_watch_element((Bucket *) zv, element);
phpdbg_watch_parent_ht(element);
} else {
return 0;
return false;
}
return 1;
return true;
}
void phpdbg_automatic_dequeue_free(phpdbg_watch_element *element) {

View file

@ -115,9 +115,9 @@ void phpdbg_destroy_watchpoints(void);
void phpdbg_purge_watchpoint_tree(void);
#ifndef _WIN32
int phpdbg_watchpoint_segfault_handler(siginfo_t *info, void *context);
zend_result phpdbg_watchpoint_segfault_handler(siginfo_t *info, void *context);
#else
int phpdbg_watchpoint_segfault_handler(void *addr);
zend_result phpdbg_watchpoint_segfault_handler(void *addr);
#endif
void phpdbg_create_addr_watchpoint(void *addr, size_t size, phpdbg_watchpoint_t *watch);