Skip to content

tree: use ZSTR_VAL()/ZSTR_LEN() instead of direct zend_string member access - #25375

Merged
Girgias merged 5 commits into
php:masterfrom
adapik:api-macros
Nov 11, 2026
Merged

Girgias merged 5 commits into
php:masterfrom
adapik:api-macros

Conversation

@adapik

@adapik adapik commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Replace direct ->val / ->len accesses on zend_string with the ZSTR_VAL() / ZSTR_LEN() macros in the few places that still bypass them.

No functional change. I built master and the resulting binary are byte-for-byte identical.

Each file is a separate commit so they can be dropped or reviewed individually.

Similar to #24330 and 35e96f6. Going through the macros means these places don't break if the layout of zend_string changes, and most of the tree already does it.

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some good follow-ups

Comment thread ext/zend_test/test.c
if (!type_matches) {
zend_string *ty = zend_type_to_string(arginfo_zend_test_internal_dnf_arguments[1].type);
zend_argument_type_error(1, "must be of type %s, %s given", ty->val, obj->ce->name->val);
zend_argument_type_error(1, "must be of type %s, %s given", ZSTR_VAL(ty), ZSTR_VAL(obj->ce->name));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
zend_argument_type_error(1, "must be of type %s, %s given", ZSTR_VAL(ty), ZSTR_VAL(obj->ce->name));
zend_argument_type_error(1, "must be of type %pS, %pS given", ty, obj->ce->name);

Comment thread ext/zend_test/test.c
if (!type_matches) {
zend_string *ty = zend_type_to_string(execute_data->func->internal_function.arg_info->type);
zend_argument_type_error(1, "must be of type %s, %s given", ty->val, obj->ce->name->val);
zend_argument_type_error(1, "must be of type %s, %s given", ZSTR_VAL(ty), ZSTR_VAL(obj->ce->name));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
zend_argument_type_error(1, "must be of type %s, %s given", ZSTR_VAL(ty), ZSTR_VAL(obj->ce->name));
zend_argument_type_error(1, "must be of type %pS, %pS given", ty, obj->ce->name);

Comment thread ext/standard/mail.c
time(&curtime);
date_str = php_format_date("d-M-Y H:i:s e", 13, curtime, 1);
len = spprintf(&tmp, 0, "[%s] %s%s", date_str->val, logline, PHP_EOL);
len = spprintf(&tmp, 0, "[%s] %s%s", ZSTR_VAL(date_str), logline, PHP_EOL);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
len = spprintf(&tmp, 0, "[%s] %s%s", ZSTR_VAL(date_str), logline, PHP_EOL);
len = spprintf(&tmp, 0, "[%pS] %s%s", date_str, logline, PHP_EOL);

@Girgias
Girgias merged commit b849968 into php:master Nov 11, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants