Skip to content

ext: make lots of internal functions static #10650

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

Merged
merged 4 commits into from
Feb 21, 2023
Merged
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
2 changes: 1 addition & 1 deletion ext/curl/multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ static zend_function *curl_multi_get_constructor(zend_object *object) {
return NULL;
}

void curl_multi_free_obj(zend_object *object)
static void curl_multi_free_obj(zend_object *object)
{
php_curlm *mh = curl_multi_from_obj(object);

Expand Down
4 changes: 2 additions & 2 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ static timelib_tzinfo *php_date_parse_tzfile(const char *formal_tzname, const ti
return tzi;
}

timelib_tzinfo *php_date_parse_tzfile_wrapper(const char *formal_tzname, const timelib_tzdb *tzdb, int *dummy_error_code)
static timelib_tzinfo *php_date_parse_tzfile_wrapper(const char *formal_tzname, const timelib_tzdb *tzdb, int *dummy_error_code)
{
return php_date_parse_tzfile(formal_tzname, tzdb);
}
Expand Down Expand Up @@ -2947,7 +2947,7 @@ PHP_FUNCTION(date_get_last_errors)
}
/* }}} */

void php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAMETERS, timelib_time *parsed_time, timelib_error_container *error) /* {{{ */
static void php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAMETERS, timelib_time *parsed_time, timelib_error_container *error) /* {{{ */
{
zval element;

Expand Down
6 changes: 3 additions & 3 deletions ext/dba/dba.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ static void dba_close_rsrc(zend_resource *rsrc)
/* }}} */

/* {{{ dba_close_pe_rsrc_deleter */
int dba_close_pe_rsrc_deleter(zval *el, void *pDba)
static int dba_close_pe_rsrc_deleter(zval *el, void *pDba)
{
if (Z_RES_P(el)->ptr == pDba) {
if (Z_DELREF_P(el) == 0) {
Expand All @@ -318,7 +318,7 @@ static void dba_close_pe_rsrc(zend_resource *rsrc)
/* }}} */

/* {{{ PHP_INI */
ZEND_INI_MH(OnUpdateDefaultHandler)
static ZEND_INI_MH(OnUpdateDefaultHandler)
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to modify the definition of ZEND_INI_MH to include the static?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about that, but after I saw it's already used that way a lot (54 times), I decided it's a whole different refactoring case and didn't check if it breaks anything. e.g.:

static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */

Copy link
Member

Choose a reason for hiding this comment

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

Huh, didn't even realize that we were already doing this elsewhere. Makes sense then to just add it here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And: adding static to the macro would be a breaking change; it would break all extensions which already use static.

{
const dba_handler *hptr;

Expand Down Expand Up @@ -431,7 +431,7 @@ static void php_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode)
/* }}} */

/* {{{ php_find_dbm */
dba_info *php_dba_find(const char* path)
static dba_info *php_dba_find(const char* path)
{
zend_resource *le;
dba_info *info;
Expand Down
2 changes: 1 addition & 1 deletion ext/libxml/libxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...)
va_end(args);
}

PHP_LIBXML_API void php_libxml_structured_error_handler(void *userData, xmlErrorPtr error)
static void php_libxml_structured_error_handler(void *userData, xmlErrorPtr error)
{
_php_list_set_error_structure(error, NULL);

Expand Down
2 changes: 1 addition & 1 deletion ext/sqlite3/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void sqlite3_param_dtor(zval *data);
static int php_sqlite3_compare_stmt_zval_free(php_sqlite3_free_list **free_list, zval *statement);

/* {{{ Error Handler */
static void php_sqlite3_error(php_sqlite3_db_object *db_obj, char *format, ...)
static void php_sqlite3_error(php_sqlite3_db_object *db_obj, const char *format, ...)
{
va_list arg;
char *message;
Expand Down