Skip to content

Commit 8e62e2b

Browse files
authored
Mark multple functions as static (#13864)
* Mark many functions as static Multiple functions are missing the static qualifier. * remove unused struct sigactions struct sigaction act, old_term, old_quit, old_int; all unused. * optimizer: minXOR and maxXOR are unused
1 parent 46540a0 commit 8e62e2b

37 files changed

+75
-88
lines changed

Zend/Optimizer/zend_inference.c

+4-14
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, ze
543543
/* }}} */
544544

545545
/* From "Hacker's Delight" */
546-
zend_ulong minOR(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
546+
static zend_ulong minOR(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
547547
{
548548
zend_ulong m, temp;
549549

@@ -567,7 +567,7 @@ zend_ulong minOR(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
567567
return a | c;
568568
}
569569

570-
zend_ulong maxOR(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
570+
static zend_ulong maxOR(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
571571
{
572572
zend_ulong m, temp;
573573

@@ -590,7 +590,7 @@ zend_ulong maxOR(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
590590
return b | d;
591591
}
592592

593-
zend_ulong minAND(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
593+
static zend_ulong minAND(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
594594
{
595595
zend_ulong m, temp;
596596

@@ -613,7 +613,7 @@ zend_ulong minAND(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
613613
return a & c;
614614
}
615615

616-
zend_ulong maxAND(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
616+
static zend_ulong maxAND(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
617617
{
618618
zend_ulong m, temp;
619619

@@ -637,16 +637,6 @@ zend_ulong maxAND(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
637637
return b & d;
638638
}
639639

640-
zend_ulong minXOR(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
641-
{
642-
return minAND(a, b, ~d, ~c) | minAND(~b, ~a, c, d);
643-
}
644-
645-
zend_ulong maxXOR(zend_ulong a, zend_ulong b, zend_ulong c, zend_ulong d)
646-
{
647-
return maxOR(0, maxAND(a, b, ~d, ~c), 0, maxAND(~b, ~a, c, d));
648-
}
649-
650640
/* Based on "Hacker's Delight" */
651641

652642
/*

Zend/zend_ast.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ static zend_result zend_ast_add_unpacked_element(zval *result, zval *expr) {
491491
return FAILURE;
492492
}
493493

494-
zend_class_entry *zend_ast_fetch_class(zend_ast *ast, zend_class_entry *scope)
494+
static zend_class_entry *zend_ast_fetch_class(zend_ast *ast, zend_class_entry *scope)
495495
{
496496
return zend_fetch_class_with_scope(zend_ast_get_str(ast), (ast->attr >> ZEND_CONST_EXPR_NEW_FETCH_TYPE_SHIFT) | ZEND_FETCH_CLASS_EXCEPTION, scope);
497497
}

Zend/zend_builtin_functions.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ZEND_MINIT_FUNCTION(core) { /* {{{ */
4343
}
4444
/* }}} */
4545

46-
zend_module_entry zend_builtin_module = { /* {{{ */
46+
static zend_module_entry zend_builtin_module = { /* {{{ */
4747
STANDARD_MODULE_HEADER,
4848
"Core",
4949
ext_functions,

Zend/zend_compile.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ static zend_string *zend_resolve_class_name(zend_string *name, uint32_t type) /*
11491149
}
11501150
/* }}} */
11511151

1152-
zend_string *zend_resolve_class_name_ast(zend_ast *ast) /* {{{ */
1152+
static zend_string *zend_resolve_class_name_ast(zend_ast *ast) /* {{{ */
11531153
{
11541154
zval *class_name = zend_ast_get_zval(ast);
11551155
if (Z_TYPE_P(class_name) != IS_STRING) {

Zend/zend_generators.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ static const zend_object_iterator_funcs zend_generator_iterator_functions = {
11351135
};
11361136

11371137
/* by_ref is int due to Iterator API */
1138-
zend_object_iterator *zend_generator_get_iterator(zend_class_entry *ce, zval *object, int by_ref) /* {{{ */
1138+
static zend_object_iterator *zend_generator_get_iterator(zend_class_entry *ce, zval *object, int by_ref) /* {{{ */
11391139
{
11401140
zend_object_iterator *iterator;
11411141
zend_generator *generator = (zend_generator*)Z_OBJ_P(object);

Zend/zend_inheritance.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ static void do_inherit_method(zend_string *key, zend_function *parent, zend_clas
12391239
}
12401240
/* }}} */
12411241

1242-
inheritance_status property_types_compatible(
1242+
static inheritance_status property_types_compatible(
12431243
const zend_property_info *parent_info, const zend_property_info *child_info) {
12441244
if (ZEND_TYPE_PURE_MASK(parent_info->type) == ZEND_TYPE_PURE_MASK(child_info->type)
12451245
&& ZEND_TYPE_NAME(parent_info->type) == ZEND_TYPE_NAME(child_info->type)) {

Zend/zend_ini_parser.y

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "win32/syslog.h"
3333
#endif
3434

35-
int ini_parse(void);
35+
static int ini_parse(void);
3636

3737
#define ZEND_INI_PARSER_CB (CG(ini_parser_param))->ini_parser_cb
3838
#define ZEND_INI_PARSER_ARG (CG(ini_parser_param))->arg

Zend/zend_observer.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
#define ZEND_OBSERVABLE_FN(function) \
3333
(ZEND_MAP_PTR(function->common.run_time_cache) && !(function->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE))
3434

35-
zend_llist zend_observers_fcall_list;
36-
zend_llist zend_observer_function_declared_callbacks;
37-
zend_llist zend_observer_class_linked_callbacks;
38-
zend_llist zend_observer_error_callbacks;
39-
zend_llist zend_observer_fiber_init;
40-
zend_llist zend_observer_fiber_switch;
41-
zend_llist zend_observer_fiber_destroy;
35+
static zend_llist zend_observers_fcall_list;
36+
static zend_llist zend_observer_function_declared_callbacks;
37+
static zend_llist zend_observer_class_linked_callbacks;
38+
static zend_llist zend_observer_error_callbacks;
39+
static zend_llist zend_observer_fiber_init;
40+
static zend_llist zend_observer_fiber_switch;
41+
static zend_llist zend_observer_fiber_destroy;
4242

4343
int zend_observer_fcall_op_array_extension;
4444
int zend_observer_fcall_internal_function_extension;

Zend/zend_signal.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static sigset_t global_sigmask;
8181

8282
/* {{{ zend_signal_handler_defer
8383
* Blocks signals if in critical section */
84-
void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context)
84+
static void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context)
8585
{
8686
int errno_save = errno;
8787
zend_signal_queue_t *queue, *qtmp;

Zend/zend_weakrefs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ typedef struct _zend_weakmap_iterator {
5454
#define ZEND_WEAKREF_ENCODE(p, t) ((void *) (((uintptr_t) (p)) | (t)))
5555

5656
zend_class_entry *zend_ce_weakref;
57-
zend_class_entry *zend_ce_weakmap;
57+
static zend_class_entry *zend_ce_weakmap;
5858
static zend_object_handlers zend_weakref_handlers;
5959
static zend_object_handlers zend_weakmap_handlers;
6060

ext/date/php_date.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ PHP_INI_BEGIN()
267267
PHP_INI_END()
268268
/* }}} */
269269

270-
zend_class_entry *date_ce_date, *date_ce_timezone, *date_ce_interval, *date_ce_period;
271-
zend_class_entry *date_ce_immutable, *date_ce_interface;
272-
zend_class_entry *date_ce_date_error, *date_ce_date_object_error, *date_ce_date_range_error;
273-
zend_class_entry *date_ce_date_exception, *date_ce_date_invalid_timezone_exception, *date_ce_date_invalid_operation_exception, *date_ce_date_malformed_string_exception, *date_ce_date_malformed_interval_string_exception, *date_ce_date_malformed_period_string_exception;
270+
static zend_class_entry *date_ce_date, *date_ce_timezone, *date_ce_interval, *date_ce_period;
271+
static zend_class_entry *date_ce_immutable, *date_ce_interface;
272+
static zend_class_entry *date_ce_date_error, *date_ce_date_object_error, *date_ce_date_range_error;
273+
static zend_class_entry *date_ce_date_exception, *date_ce_date_invalid_timezone_exception, *date_ce_date_invalid_operation_exception, *date_ce_date_malformed_string_exception, *date_ce_date_malformed_interval_string_exception, *date_ce_date_malformed_period_string_exception;
274274

275275

276276
PHPAPI zend_class_entry *php_date_get_date_ce(void)

ext/hash/hash.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# endif
4242
#endif
4343

44-
HashTable php_hash_hashtable;
44+
static HashTable php_hash_hashtable;
4545
zend_class_entry *php_hashcontext_ce;
4646
static zend_object_handlers php_hashcontext_handlers;
4747

ext/iconv/iconv.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
#define PHP_ICONV_IMPL_VALUE "unknown"
6565
#endif
6666

67-
char *get_iconv_version(void) {
67+
static char *get_iconv_version(void) {
6868
char *version = "unknown";
6969

7070
#ifdef HAVE_LIBICONV

ext/opcache/ZendAccelerator.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1877,7 +1877,7 @@ static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handl
18771877
return new_persistent_script;
18781878
}
18791879

1880-
zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type)
1880+
static zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type)
18811881
{
18821882
zend_persistent_script *persistent_script;
18831883
zend_op_array *op_array = NULL;

ext/openssl/openssl.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ typedef struct _php_openssl_x509_request_object {
185185
zend_object std;
186186
} php_openssl_request_object;
187187

188-
zend_class_entry *php_openssl_request_ce;
188+
static zend_class_entry *php_openssl_request_ce;
189189

190190
static inline php_openssl_request_object *php_openssl_request_from_obj(zend_object *obj) {
191191
return (php_openssl_request_object *)((char *)(obj) - XtOffsetOf(php_openssl_request_object, std));
@@ -225,7 +225,7 @@ typedef struct _php_openssl_pkey_object {
225225
zend_object std;
226226
} php_openssl_pkey_object;
227227

228-
zend_class_entry *php_openssl_pkey_ce;
228+
static zend_class_entry *php_openssl_pkey_ce;
229229

230230
static inline php_openssl_pkey_object *php_openssl_pkey_from_obj(zend_object *obj) {
231231
return (php_openssl_pkey_object *)((char *)(obj) - XtOffsetOf(php_openssl_pkey_object, std));
@@ -486,7 +486,7 @@ void php_openssl_store_errors(void)
486486
/* }}} */
487487

488488
/* {{{ php_openssl_errors_set_mark */
489-
void php_openssl_errors_set_mark(void) {
489+
static void php_openssl_errors_set_mark(void) {
490490
if (!OPENSSL_G(errors)) {
491491
return;
492492
}
@@ -500,7 +500,7 @@ void php_openssl_errors_set_mark(void) {
500500
/* }}} */
501501

502502
/* {{{ php_openssl_errors_restore_mark */
503-
void php_openssl_errors_restore_mark(void) {
503+
static void php_openssl_errors_restore_mark(void) {
504504
if (!OPENSSL_G(errors)) {
505505
return;
506506
}

ext/openssl/xp_ssl.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static struct timeval php_openssl_subtract_timeval(struct timeval a, struct time
159159
static int php_openssl_compare_timeval(struct timeval a, struct timeval b);
160160
static ssize_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, size_t count);
161161

162-
const php_stream_ops php_openssl_socket_ops;
162+
static const php_stream_ops php_openssl_socket_ops;
163163

164164
/* Certificate contexts used for server-side SNI selection */
165165
typedef struct _php_openssl_sni_cert_t {
@@ -1650,7 +1650,7 @@ static int php_openssl_server_alpn_callback(SSL *ssl_handle,
16501650

16511651
#endif
16521652

1653-
zend_result php_openssl_setup_crypto(php_stream *stream,
1653+
static zend_result php_openssl_setup_crypto(php_stream *stream,
16541654
php_openssl_netstream_data_t *sslsock,
16551655
php_stream_xport_crypto_param *cparam) /* {{{ */
16561656
{
@@ -2701,7 +2701,7 @@ static int php_openssl_sockop_cast(php_stream *stream, int castas, void **ret)
27012701
}
27022702
/* }}} */
27032703

2704-
const php_stream_ops php_openssl_socket_ops = {
2704+
static const php_stream_ops php_openssl_socket_ops = {
27052705
php_openssl_sockop_write, php_openssl_sockop_read,
27062706
php_openssl_sockop_close, php_openssl_sockop_flush,
27072707
"tcp_socket/ssl",

ext/phar/dirstream.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stream_statbuf *ssb, bool is_dir);
2525

26-
const php_stream_ops phar_dir_ops = {
26+
static const php_stream_ops phar_dir_ops = {
2727
phar_dir_write, /* write */
2828
phar_dir_read, /* read */
2929
phar_dir_close, /* close */

ext/phar/stream.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "stream.h"
2323
#include "dirstream.h"
2424

25-
const php_stream_ops phar_ops = {
25+
static const php_stream_ops phar_ops = {
2626
phar_stream_write, /* write */
2727
phar_stream_read, /* read */
2828
phar_stream_close, /* close */
@@ -34,7 +34,7 @@ const php_stream_ops phar_ops = {
3434
NULL, /* set option */
3535
};
3636

37-
const php_stream_wrapper_ops phar_stream_wops = {
37+
static const php_stream_wrapper_ops phar_stream_wops = {
3838
phar_wrapper_open_url,
3939
NULL, /* phar_wrapper_close */
4040
NULL, /* phar_wrapper_stat, */

ext/spl/spl_iterators.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2868,7 +2868,7 @@ PHP_METHOD(EmptyIterator, next)
28682868
}
28692869
} /* }}} */
28702870

2871-
zend_result spl_append_it_next_iterator(spl_dual_it_object *intern) /* {{{*/
2871+
static zend_result spl_append_it_next_iterator(spl_dual_it_object *intern) /* {{{*/
28722872
{
28732873
spl_dual_it_free(intern);
28742874

ext/spl/spl_observer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static inline spl_SplObjectStorage *spl_object_storage_from_obj(zend_object *obj
7373

7474
#define Z_SPLOBJSTORAGE_P(zv) spl_object_storage_from_obj(Z_OBJ_P((zv)))
7575

76-
void spl_SplObjectStorage_free_storage(zend_object *object) /* {{{ */
76+
static void spl_SplObjectStorage_free_storage(zend_object *object) /* {{{ */
7777
{
7878
spl_SplObjectStorage *intern = spl_object_storage_from_obj(object);
7979

ext/sqlite3/sqlite3.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ static zend_object_handlers sqlite3_stmt_object_handlers;
7272
static zend_object_handlers sqlite3_result_object_handlers;
7373

7474
/* Class entries */
75-
zend_class_entry *php_sqlite3_exception_ce;
76-
zend_class_entry *php_sqlite3_sc_entry;
77-
zend_class_entry *php_sqlite3_stmt_entry;
75+
static zend_class_entry *php_sqlite3_exception_ce;
76+
static zend_class_entry *php_sqlite3_sc_entry;
77+
static zend_class_entry *php_sqlite3_stmt_entry;
7878
zend_class_entry *php_sqlite3_result_entry;
7979

8080
/* {{{ Error Handler */

ext/standard/ftp_fopen_wrapper.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ static const php_stream_ops php_ftp_dirstream_ops = {
678678
};
679679

680680
/* {{{ php_stream_ftp_opendir */
681-
php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options,
681+
static php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options,
682682
zend_string **opened_path, php_stream_context *context STREAMS_DC)
683683
{
684684
php_stream *stream, *reuseid, *datastream = NULL;

ext/standard/mail.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ PHP_FUNCTION(mail)
341341
/* }}} */
342342

343343

344-
void php_mail_log_crlf_to_spaces(char *message) {
344+
static void php_mail_log_crlf_to_spaces(char *message) {
345345
/* Find all instances of carriage returns or line feeds and
346346
* replace them with spaces. Thus, a log line is always one line
347347
* long
@@ -352,15 +352,15 @@ void php_mail_log_crlf_to_spaces(char *message) {
352352
}
353353
}
354354

355-
void php_mail_log_to_syslog(char *message) {
355+
static void php_mail_log_to_syslog(char *message) {
356356
/* Write 'message' to syslog. */
357357
#ifdef HAVE_SYSLOG_H
358358
php_syslog(LOG_NOTICE, "%s", message);
359359
#endif
360360
}
361361

362362

363-
void php_mail_log_to_file(char *filename, char *message, size_t message_size) {
363+
static void php_mail_log_to_file(char *filename, char *message, size_t message_size) {
364364
/* Write 'message' to the given file. */
365365
uint32_t flags = REPORT_ERRORS | STREAM_DISABLE_OPEN_BASEDIR;
366366
php_stream *stream = php_stream_open_wrapper(filename, "a", flags, NULL);

ext/standard/php_fopen_wrapper.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static int php_stream_output_close(php_stream *stream, int close_handle) /* {{{
4949
}
5050
/* }}} */
5151

52-
const php_stream_ops php_stream_output_ops = {
52+
static const php_stream_ops php_stream_output_ops = {
5353
php_stream_output_write,
5454
php_stream_output_read,
5555
php_stream_output_close,
@@ -134,7 +134,7 @@ static int php_stream_input_seek(php_stream *stream, zend_off_t offset, int when
134134
}
135135
/* }}} */
136136

137-
const php_stream_ops php_stream_input_ops = {
137+
static const php_stream_ops php_stream_input_ops = {
138138
php_stream_input_write,
139139
php_stream_input_read,
140140
php_stream_input_close,
@@ -173,7 +173,7 @@ static void php_stream_apply_filter_list(php_stream *stream, char *filterlist, i
173173
}
174174
/* }}} */
175175

176-
php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *path, const char *mode, int options,
176+
static php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *path, const char *mode, int options,
177177
zend_string **opened_path, php_stream_context *context STREAMS_DC) /* {{{ */
178178
{
179179
int fd = -1;

ext/standard/user_filters.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static void userfilter_dtor(php_stream_filter *thisfilter)
123123
zval_ptr_dtor(obj);
124124
}
125125

126-
php_stream_filter_status_t userfilter_filter(
126+
static php_stream_filter_status_t userfilter_filter(
127127
php_stream *stream,
128128
php_stream_filter *thisfilter,
129129
php_stream_bucket_brigade *buckets_in,

ext/tokenizer/tokenizer.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#define zendcursor LANG_SCNG(yy_cursor)
3939
#define zendlimit LANG_SCNG(yy_limit)
4040

41-
zend_class_entry *php_token_ce;
41+
static zend_class_entry *php_token_ce;
4242

4343
/* {{{ tokenizer_module_entry */
4444
zend_module_entry tokenizer_module_entry = {
@@ -410,7 +410,7 @@ static zval *extract_token_id_to_replace(zval *token_zv, const char *text, size_
410410
return NULL;
411411
}
412412

413-
void on_event(
413+
static void on_event(
414414
zend_php_scanner_event event, int token, int line,
415415
const char *text, size_t length, void *context)
416416
{

0 commit comments

Comments
 (0)