From 11d10607bc03a388c4e31b3cb4ff2d1ef2153a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 23 Sep 2025 22:52:07 +0200 Subject: [PATCH] phar: Use `true` / `false` instead of `1` / `0` when assigning to `bool` Changes done with Coccinelle: @@ bool b; @@ - b = 0 + b = false @@ bool b; @@ - b = 1 + b = true --- ext/phar/func_interceptors.c | 8 ++++---- ext/phar/phar_object.c | 18 +++++++++--------- ext/phar/tar.c | 8 ++++---- ext/phar/zip.c | 6 +++--- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c index f1b2b0eba1e..976ce0b5e95 100644 --- a/ext/phar/func_interceptors.c +++ b/ext/phar/func_interceptors.c @@ -159,10 +159,10 @@ PHP_FUNCTION(phar_file_get_contents) /* {{{ */ { zend_string *filename; zend_string *contents; - bool use_include_path = 0; + bool use_include_path = false; zend_long offset = -1; zend_long maxlen; - bool maxlen_is_null = 1; + bool maxlen_is_null = true; zval *zcontext = NULL; if (!PHAR_G(intercepted)) { @@ -235,7 +235,7 @@ skip_phar: PHP_FUNCTION(phar_readfile) /* {{{ */ { zend_string *filename; - bool use_include_path = 0; + bool use_include_path = false; zval *zcontext = NULL; if (!PHAR_G(intercepted)) { @@ -281,7 +281,7 @@ PHP_FUNCTION(phar_fopen) /* {{{ */ zend_string *filename; char *mode; size_t mode_len; - bool use_include_path = 0; + bool use_include_path = false; zval *zcontext = NULL; if (!PHAR_G(intercepted)) { diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index e584338b23e..c30145d9fb9 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -403,7 +403,7 @@ PHP_METHOD(Phar, running) zend_string *fname; char *arch, *entry; size_t arch_len, entry_len; - bool retphar = 1; + bool retphar = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &retphar) == FAILURE) { RETURN_THROWS(); @@ -1060,7 +1060,7 @@ PHP_METHOD(Phar, isValidPharFilename) size_t fname_len; size_t ext_len; int is_executable; - bool executable = 1; + bool executable = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { RETURN_THROWS(); @@ -1393,7 +1393,7 @@ struct _phar_t { static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ { zval *value; - bool close_fp = 1; + bool close_fp = true; struct _phar_t *p_obj = (struct _phar_t*) puser; size_t str_key_len, base_len = ZSTR_LEN(p_obj->base); phar_entry_data *data; @@ -1455,7 +1455,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ return ZEND_HASH_APPLY_STOP; } - close_fp = 0; + close_fp = false; opened = ZSTR_INIT_LITERAL("[stream]", 0); goto after_open_fp; case IS_OBJECT: @@ -1714,7 +1714,7 @@ after_open_fp: PHP_METHOD(Phar, buildFromDirectory) { char *error; - bool apply_reg = 0; + bool apply_reg = false; zval arg, arg2, iter, iteriter, regexiter; struct _phar_t pass; zend_string *dir, *regex = NULL; @@ -1767,7 +1767,7 @@ PHP_METHOD(Phar, buildFromDirectory) zval_ptr_dtor(&iter); if (regex && ZSTR_LEN(regex) > 0) { - apply_reg = 1; + apply_reg = true; if (SUCCESS != object_init_ex(®exiter, spl_ce_RegexIterator)) { zval_ptr_dtor(&iteriter); @@ -2360,7 +2360,7 @@ PHP_METHOD(Phar, convertToExecutable) uint32_t flags; zend_object *ret; zend_long format, method; - bool format_is_null = 1, method_is_null = 1; + bool format_is_null = true, method_is_null = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!l!s!", &format, &format_is_null, &method, &method_is_null, &ext, &ext_len) == FAILURE) { RETURN_THROWS(); @@ -2471,7 +2471,7 @@ PHP_METHOD(Phar, convertToData) uint32_t flags; zend_object *ret; zend_long format, method; - bool format_is_null = 1, method_is_null = 1; + bool format_is_null = true, method_is_null = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!l!s!", &format, &format_is_null, &method, &method_is_null, &ext, &ext_len) == FAILURE) { RETURN_THROWS(); @@ -4574,7 +4574,7 @@ PHP_METHOD(PharFileInfo, getCompressedSize) PHP_METHOD(PharFileInfo, isCompressed) { zend_long method; - bool method_is_null = 1; + bool method_is_null = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &method, &method_is_null) == FAILURE) { RETURN_THROWS(); diff --git a/ext/phar/tar.c b/ext/phar/tar.c index 0f90104014c..d8c412b5a9b 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -845,10 +845,10 @@ static int phar_tar_writeheaders_int(phar_entry_info *entry, void *argument) /* /* open file pointers refer to this fp, do not free the stream */ switch (entry->fp_type) { case PHAR_FP: - fp->free_fp = 0; + fp->free_fp = false; break; case PHAR_UFP: - fp->free_ufp = 0; + fp->free_ufp = false; default: break; } @@ -1118,8 +1118,8 @@ nostub: pass.old = oldfile; pass.new = newfile; pass.error = error; - pass.free_fp = 1; - pass.free_ufp = 1; + pass.free_fp = true; + pass.free_ufp = true; if (phar_metadata_tracker_has_data(&phar->metadata_tracker, phar->is_persistent)) { phar_entry_info *mentry; diff --git a/ext/phar/zip.c b/ext/phar/zip.c index 0ee958bda24..a836d52d25d 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -1145,10 +1145,10 @@ continue_dir: /* open file pointers refer to this fp, do not free the stream */ switch (entry->fp_type) { case PHAR_FP: - p->free_fp = 0; + p->free_fp = false; break; case PHAR_UFP: - p->free_ufp = 0; + p->free_ufp = false; default: break; } @@ -1422,7 +1422,7 @@ fperror: goto fperror; } - pass.free_fp = pass.free_ufp = 1; + pass.free_fp = pass.free_ufp = true; memset(&eocd, 0, sizeof(eocd)); memcpy(eocd.signature, "PK\5\6", 4);