Skip to content

Various return types and values consolidation #19418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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));
}
Expand Down
8 changes: 2 additions & 6 deletions ext/standard/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 */
Expand Down
24 changes: 12 additions & 12 deletions main/php_variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,15 @@ 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;
vsep = memchr(start, '&', var->end - start);
if (!vsep) {
if (!eof) {
var->already_scanned = var->end - var->ptr;
return 0;
return false;
} else {
vsep = var->end;
}
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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();
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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 */
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion main/php_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions sapi/phpdbg/phpdbg_watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions sapi/phpdbg/phpdbg_watch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down