Skip to content

Commit 04c85a3

Browse files
MaxKellermannGirgias
authored andcommitted
ext/opcache/ZendAccelerator: fix functions to return zend_result
If a function returns SUCCESS or FAILURE, it should be declared to return the enum that defines those values.
1 parent a50de37 commit 04c85a3

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static ZEND_INI_MH((*orig_include_path_on_modify)) = NULL;
129129
static zend_result (*orig_post_startup_cb)(void);
130130

131131
static zend_result accel_post_startup(void);
132-
static int accel_finish_startup(void);
132+
static zend_result accel_finish_startup(void);
133133

134134
static void preload_shutdown(void);
135135
static void preload_activate(void);
@@ -1165,7 +1165,7 @@ static inline int do_validate_timestamps(zend_persistent_script *persistent_scri
11651165
return ret;
11661166
}
11671167

1168-
int validate_timestamp_and_record(zend_persistent_script *persistent_script, zend_file_handle *file_handle)
1168+
zend_result validate_timestamp_and_record(zend_persistent_script *persistent_script, zend_file_handle *file_handle)
11691169
{
11701170
if (persistent_script->timestamp == 0) {
11711171
return SUCCESS; /* Don't check timestamps of preloaded scripts */
@@ -1180,12 +1180,10 @@ int validate_timestamp_and_record(zend_persistent_script *persistent_script, zen
11801180
}
11811181
}
11821182

1183-
int validate_timestamp_and_record_ex(zend_persistent_script *persistent_script, zend_file_handle *file_handle)
1183+
zend_result validate_timestamp_and_record_ex(zend_persistent_script *persistent_script, zend_file_handle *file_handle)
11841184
{
1185-
int ret;
1186-
11871185
SHM_UNPROTECT();
1188-
ret = validate_timestamp_and_record(persistent_script, file_handle);
1186+
const zend_result ret = validate_timestamp_and_record(persistent_script, file_handle);
11891187
SHM_PROTECT();
11901188

11911189
return ret;
@@ -1398,7 +1396,7 @@ static void zend_accel_lock_discard_script(zend_persistent_script *persistent_sc
13981396
zend_shared_alloc_unlock();
13991397
}
14001398

1401-
int zend_accel_invalidate(zend_string *filename, bool force)
1399+
zend_result zend_accel_invalidate(zend_string *filename, bool force)
14021400
{
14031401
zend_string *realpath;
14041402
zend_persistent_script *persistent_script;
@@ -2476,7 +2474,7 @@ static zend_class_entry* zend_accel_inheritance_cache_add(zend_class_entry *ce,
24762474
}
24772475

24782476
#ifdef ZEND_WIN32
2479-
static int accel_gen_uname_id(void)
2477+
static zend_result accel_gen_uname_id(void)
24802478
{
24812479
PHP_MD5_CTX ctx;
24822480
unsigned char digest[16];
@@ -2819,7 +2817,7 @@ static void zps_startup_failure(char *reason, char *api_reason, int (*cb)(zend_e
28192817
zend_llist_del_element(&zend_extensions, NULL, (int (*)(void *, void *))cb);
28202818
}
28212819

2822-
static inline int accel_find_sapi(void)
2820+
static inline zend_result accel_find_sapi(void)
28232821
{
28242822
static const char *supported_sapis[] = {
28252823
"apache",
@@ -2853,7 +2851,7 @@ static inline int accel_find_sapi(void)
28532851
return FAILURE;
28542852
}
28552853

2856-
static int zend_accel_init_shm(void)
2854+
static zend_result zend_accel_init_shm(void)
28572855
{
28582856
int i;
28592857
size_t accel_shared_globals_size;
@@ -3458,7 +3456,7 @@ static void accel_deactivate_now(void)
34583456
if OK returns SUCCESS
34593457
MUST call accelerator_shm_read_unlock after done lock operations
34603458
*/
3461-
int accelerator_shm_read_lock(void)
3459+
zend_result accelerator_shm_read_lock(void)
34623460
{
34633461
if (ZCG(counted)) {
34643462
/* counted means we are holding read lock for SHM, so that nothing bad can happen */
@@ -4335,10 +4333,10 @@ static void preload_load(void)
43354333
}
43364334
}
43374335

4338-
static int accel_preload(const char *config, bool in_child)
4336+
static zend_result accel_preload(const char *config, bool in_child)
43394337
{
43404338
zend_file_handle file_handle;
4341-
int ret;
4339+
zend_result ret;
43424340
char *orig_open_basedir;
43434341
size_t orig_map_ptr_last;
43444342
uint32_t orig_compiler_options;
@@ -4585,10 +4583,9 @@ static void preload_send_header(sapi_header_struct *sapi_header, void *server_co
45854583
}
45864584

45874585
#ifndef ZEND_WIN32
4588-
static int accel_finish_startup_preload(bool in_child)
4586+
static zend_result accel_finish_startup_preload(bool in_child)
45894587
{
4590-
int ret = SUCCESS;
4591-
int rc;
4588+
zend_result ret = SUCCESS;
45924589
int orig_error_reporting;
45934590

45944591
int (*orig_activate)(void) = sapi_module.activate;
@@ -4623,7 +4620,7 @@ static int accel_finish_startup_preload(bool in_child)
46234620
orig_error_reporting = EG(error_reporting);
46244621
EG(error_reporting) = 0;
46254622

4626-
rc = php_request_startup();
4623+
const zend_result rc = php_request_startup();
46274624

46284625
EG(error_reporting) = orig_error_reporting;
46294626

@@ -4683,7 +4680,7 @@ static int accel_finish_startup_preload(bool in_child)
46834680
return ret;
46844681
}
46854682

4686-
static int accel_finish_startup_preload_subprocess(pid_t *pid)
4683+
static zend_result accel_finish_startup_preload_subprocess(pid_t *pid)
46874684
{
46884685
uid_t euid = geteuid();
46894686
if (euid != 0) {
@@ -4750,7 +4747,7 @@ static int accel_finish_startup_preload_subprocess(pid_t *pid)
47504747
}
47514748
#endif /* ZEND_WIN32 */
47524749

4753-
static int accel_finish_startup(void)
4750+
static zend_result accel_finish_startup(void)
47544751
{
47554752
if (!ZCG(enabled) || !accel_startup_ok) {
47564753
return SUCCESS;
@@ -4791,7 +4788,7 @@ static int accel_finish_startup(void)
47914788
/* The called function unlocks the shared alloc lock */
47924789
return accel_finish_startup_preload(false);
47934790
} else if (pid == 0) { /* subprocess */
4794-
int ret = accel_finish_startup_preload(true);
4791+
const zend_result ret = accel_finish_startup_preload(true);
47954792

47964793
exit(ret == SUCCESS ? 0 : 1);
47974794
} else { /* parent */

ext/opcache/ZendAccelerator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ zend_result accel_post_deactivate(void);
315315
void zend_accel_schedule_restart(zend_accel_restart_reason reason);
316316
void zend_accel_schedule_restart_if_necessary(zend_accel_restart_reason reason);
317317
accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle, size_t *size);
318-
int validate_timestamp_and_record(zend_persistent_script *persistent_script, zend_file_handle *file_handle);
319-
int validate_timestamp_and_record_ex(zend_persistent_script *persistent_script, zend_file_handle *file_handle);
320-
int zend_accel_invalidate(zend_string *filename, bool force);
321-
int accelerator_shm_read_lock(void);
318+
zend_result validate_timestamp_and_record(zend_persistent_script *persistent_script, zend_file_handle *file_handle);
319+
zend_result validate_timestamp_and_record_ex(zend_persistent_script *persistent_script, zend_file_handle *file_handle);
320+
zend_result zend_accel_invalidate(zend_string *filename, bool force);
321+
zend_result accelerator_shm_read_lock(void);
322322
void accelerator_shm_read_unlock(void);
323323

324324
zend_string *accel_make_persistent_key(zend_string *path);

0 commit comments

Comments
 (0)