1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

standard: Use return true / return false for functions returning bool

Changes done with Coccinelle:

    @r1@
    identifier fn;
    typedef bool;
    symbol false;
    symbol true;
    @@

    bool fn ( ... )
    {
    <...
    return
    (
    - 0
    + false
    |
    - 1
    + true
    )
    ;
    ...>
    }

Coccinelle patch sourced from
torvalds/linux@46b5c9b856.
This commit is contained in:
Tim Düsterhus
2025-09-23 23:10:11 +02:00
committed by Tim Düsterhus
parent 60f8969f7d
commit c743b71b40
3 changed files with 10 additions and 10 deletions

View File

@@ -111,11 +111,11 @@ static bool check_has_header(const char *headers, const char *header) {
const char *s = headers;
while ((s = strstr(s, header))) {
if (s == headers || (*(s-1) == '\n' && *(s-2) == '\r')) {
return 1;
return true;
}
s++;
}
return 0;
return false;
}
static zend_result php_stream_handle_proxy_authorization_header(const char *s, smart_str *header)

View File

@@ -140,7 +140,7 @@ static bool php_password_bcrypt_needs_rehash(const zend_string *hash, zend_array
if (!php_password_bcrypt_valid(hash)) {
/* Should never get called this way. */
return 1;
return true;
}
sscanf(ZSTR_VAL(hash), "$2y$" ZEND_LONG_FMT "$", &old_cost);
@@ -156,12 +156,12 @@ static bool php_password_bcrypt_verify(const zend_string *password, const zend_s
zend_string *ret = php_crypt(ZSTR_VAL(password), (int)ZSTR_LEN(password), ZSTR_VAL(hash), (int)ZSTR_LEN(hash), 1);
if (!ret) {
return 0;
return false;
}
if (ZSTR_LEN(hash) < 13) {
zend_string_free(ret);
return 0;
return false;
}
/* We're using this method instead of == in order to provide

View File

@@ -1348,15 +1348,15 @@ static bool _is_basename_start(const char *start, const char *pos)
&& *(pos-1) != '/'
&& *(pos-1) != '\\') {
if (pos - start == 1) {
return 1;
return true;
} else if (*(pos-2) == '/' || *(pos-2) == '\\') {
return 1;
return true;
} else if (*(pos-2) == ':'
&& _is_basename_start(start, pos - 2)) {
return 1;
return true;
}
}
return 0;
return false;
}
#endif
@@ -5040,7 +5040,7 @@ static bool php_tag_find(char *tag, size_t len, const char *set) {
char *norm;
if (len == 0) {
return 0;
return false;
}
norm = emalloc(len+1);