Skip to content

Commit 1b651db

Browse files
committed
ext/opcache: use bool type instead of int
1 parent aed3acf commit 1b651db

File tree

7 files changed

+25
-26
lines changed

7 files changed

+25
-26
lines changed

ext/opcache/zend_accelerator_hash.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, zend_
138138
return entry;
139139
}
140140

141-
static zend_always_inline void* zend_accel_hash_find_ex(const zend_accel_hash *accel_hash, zend_string *key, int data)
141+
static zend_always_inline void* zend_accel_hash_find_ex(const zend_accel_hash *accel_hash, zend_string *key, bool data)
142142
{
143143
zend_ulong index;
144144
zend_accel_hash_entry *entry;
@@ -178,15 +178,15 @@ static zend_always_inline void* zend_accel_hash_find_ex(const zend_accel_hash *a
178178
*/
179179
void* zend_accel_hash_find(const zend_accel_hash *accel_hash, zend_string *key)
180180
{
181-
return zend_accel_hash_find_ex(accel_hash, key, 1);
181+
return zend_accel_hash_find_ex(accel_hash, key, true);
182182
}
183183

184184
/* Returns the hash entry associated with key on success
185185
* Returns NULL if it doesn't exist
186186
*/
187187
zend_accel_hash_entry* zend_accel_hash_find_entry(const zend_accel_hash *accel_hash, zend_string *key)
188188
{
189-
return (zend_accel_hash_entry *)zend_accel_hash_find_ex(accel_hash, key, 0);
189+
return (zend_accel_hash_entry *)zend_accel_hash_find_ex(accel_hash, key, false);
190190
}
191191

192192
int zend_accel_hash_unlink(zend_accel_hash *accel_hash, zend_string *key)

ext/opcache/zend_accelerator_module.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static zif_handler orig_file_exists = NULL;
6262
static zif_handler orig_is_file = NULL;
6363
static zif_handler orig_is_readable = NULL;
6464

65-
static int validate_api_restriction(void)
65+
static bool validate_api_restriction(void)
6666
{
6767
if (ZCG(accel_directives).restrict_api && *ZCG(accel_directives).restrict_api) {
6868
size_t len = strlen(ZCG(accel_directives).restrict_api);
@@ -71,10 +71,10 @@ static int validate_api_restriction(void)
7171
strlen(SG(request_info).path_translated) < len ||
7272
memcmp(SG(request_info).path_translated, ZCG(accel_directives).restrict_api, len) != 0) {
7373
zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " API is restricted by \"restrict_api\" configuration directive");
74-
return 0;
74+
return false;
7575
}
7676
}
77-
return 1;
77+
return true;
7878
}
7979

8080
static ZEND_INI_MH(OnUpdateMemoryConsumption)
@@ -178,8 +178,8 @@ static ZEND_INI_MH(OnEnable)
178178
}
179179
return FAILURE;
180180
} else {
181-
*p = 0;
182-
ZCG(accelerator_enabled) = 0;
181+
*p = false;
182+
ZCG(accelerator_enabled) = false;
183183
return SUCCESS;
184184
}
185185
}
@@ -363,7 +363,7 @@ ZEND_INI_BEGIN()
363363
#endif
364364
ZEND_INI_END()
365365

366-
static int filename_is_in_cache(zend_string *filename)
366+
static bool filename_is_in_cache(zend_string *filename)
367367
{
368368
zend_string *key;
369369

@@ -373,27 +373,26 @@ static int filename_is_in_cache(zend_string *filename)
373373
if (persistent_script && !persistent_script->corrupted) {
374374
if (ZCG(accel_directives).validate_timestamps) {
375375
zend_file_handle handle;
376-
int ret;
376+
bool ret;
377377

378378
zend_stream_init_filename_ex(&handle, filename);
379-
ret = validate_timestamp_and_record_ex(persistent_script, &handle) == SUCCESS
380-
? 1 : 0;
379+
ret = validate_timestamp_and_record_ex(persistent_script, &handle) == SUCCESS;
381380
zend_destroy_file_handle(&handle);
382381
return ret;
383382
}
384383

385-
return 1;
384+
return true;
386385
}
387386
}
388387

389-
return 0;
388+
return false;
390389
}
391390

392-
static int filename_is_in_file_cache(zend_string *filename)
391+
static bool filename_is_in_file_cache(zend_string *filename)
393392
{
394393
zend_string *realpath = zend_resolve_path(filename);
395394
if (!realpath) {
396-
return 0;
395+
return false;
397396
}
398397

399398
zend_file_handle handle;
@@ -406,7 +405,7 @@ static int filename_is_in_file_cache(zend_string *filename)
406405
return result != NULL;
407406
}
408407

409-
static int accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS)
408+
static bool accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS)
410409
{
411410
if (ZEND_NUM_ARGS() == 1) {
412411
zval *zv = ZEND_CALL_ARG(execute_data , 1);
@@ -415,7 +414,7 @@ static int accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS)
415414
return filename_is_in_cache(Z_STR_P(zv));
416415
}
417416
}
418-
return 0;
417+
return false;
419418
}
420419

421420
static ZEND_NAMED_FUNCTION(accel_file_exists)

ext/opcache/zend_accelerator_util_funcs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ zend_persistent_script* create_persistent_script(void)
4747
return persistent_script;
4848
}
4949

50-
void free_persistent_script(zend_persistent_script *persistent_script, int destroy_elements)
50+
void free_persistent_script(zend_persistent_script *persistent_script, bool destroy_elements)
5151
{
5252
if (!destroy_elements) {
5353
/* Both the keys and values have been transferred into the global tables.
@@ -358,7 +358,7 @@ static void zend_accel_do_delayed_early_binding(
358358
CG(in_compilation) = orig_in_compilation;
359359
}
360360

361-
zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, int from_shared_memory)
361+
zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, bool from_shared_memory)
362362
{
363363
zend_op_array *op_array;
364364

ext/opcache/zend_accelerator_util_funcs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
BEGIN_EXTERN_C()
2929

3030
zend_persistent_script* create_persistent_script(void);
31-
void free_persistent_script(zend_persistent_script *persistent_script, int destroy_elements);
31+
void free_persistent_script(zend_persistent_script *persistent_script, bool destroy_elements);
3232

3333
void zend_accel_move_user_functions(HashTable *str, uint32_t count, zend_script *script);
3434
void zend_accel_move_user_classes(HashTable *str, uint32_t count, zend_script *script);
3535
void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persistent_script);
3636
void zend_accel_finalize_delayed_early_binding_list(const zend_persistent_script *persistent_script);
3737
void zend_accel_free_delayed_early_binding_list(zend_persistent_script *persistent_script);
3838

39-
zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, int from_shared_memory);
39+
zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, bool from_shared_memory);
4040

4141
#define ADLER32_INIT 1 /* initial Adler-32 value */
4242

ext/opcache/zend_persist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ static zend_early_binding *zend_persist_early_bindings(
14211421
return early_bindings;
14221422
}
14231423

1424-
zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, int for_shm)
1424+
zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, bool for_shm)
14251425
{
14261426
Bucket *p;
14271427

ext/opcache/zend_persist.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
BEGIN_EXTERN_C()
2626

27-
uint32_t zend_accel_script_persist_calc(zend_persistent_script *script, int for_shm);
28-
zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, int for_shm);
27+
uint32_t zend_accel_script_persist_calc(zend_persistent_script *script, bool for_shm);
28+
zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, bool for_shm);
2929

3030
void zend_persist_class_entry_calc(zend_class_entry *ce);
3131
zend_class_entry *zend_persist_class_entry(zend_class_entry *ce);

ext/opcache/zend_persist_calc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ static void zend_persist_early_bindings_calc(
629629
}
630630
}
631631

632-
uint32_t zend_accel_script_persist_calc(zend_persistent_script *new_persistent_script, int for_shm)
632+
uint32_t zend_accel_script_persist_calc(zend_persistent_script *new_persistent_script, bool for_shm)
633633
{
634634
Bucket *p;
635635

0 commit comments

Comments
 (0)