From 60bcb85355527d107486190bead10394428c2e96 Mon Sep 17 00:00:00 2001 From: twosee Date: Sun, 7 Jun 2020 08:38:13 +0800 Subject: [PATCH] Fix expression warnings and break warnings --- Zend/zend_API.c | 6 +++--- Zend/zend_closures.c | 2 +- Zend/zend_compile.c | 8 ++++---- Zend/zend_object_handlers.c | 2 +- ext/date/php_date.c | 22 +++++++++++----------- ext/ffi/ffi.c | 2 +- ext/mysqlnd/mysqlnd_connection.c | 10 +++++----- ext/mysqlnd/mysqlnd_debug.h | 12 ++++++------ ext/mysqlnd/mysqlnd_wireprotocol.c | 2 +- ext/opcache/Optimizer/sccp.c | 4 ++-- ext/pdo/pdo_stmt.c | 2 +- ext/phar/stream.c | 2 +- ext/phar/util.c | 2 +- ext/reflection/php_reflection.c | 6 +++--- ext/spl/spl_dllist.c | 2 +- ext/spl/spl_functions.c | 2 +- ext/standard/array.c | 4 ++-- ext/standard/file.c | 2 +- ext/standard/flock_compat.c | 2 +- main/main.c | 2 +- main/streams/memory.c | 4 ++-- main/streams/php_stream_context.h | 2 +- main/streams/plain_wrapper.c | 1 + main/streams/streams.c | 6 +++--- main/streams/xp_socket.c | 7 +++---- sapi/cli/php_cli_server.c | 2 +- sapi/cli/php_http_parser.c | 2 +- 27 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index f65937e394322..82c5fbdf7ca15 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2154,7 +2154,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio scope->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; } } - if (ptr->flags & ZEND_ACC_STATIC && (!scope || !(scope->ce_flags & ZEND_ACC_INTERFACE))) { + if ((ptr->flags & ZEND_ACC_STATIC) && (!scope || !(scope->ce_flags & ZEND_ACC_INTERFACE))) { zend_error(error_type, "Static function %s%s%s() cannot be abstract", scope ? ZSTR_VAL(scope->name) : "", scope ? "::" : "", ptr->fname); } } else { @@ -2992,7 +2992,7 @@ static zend_always_inline int zend_is_callable_check_func(int check_flags, zval if (zv != NULL) { zend_function *priv_fbc = Z_PTR_P(zv); - if (priv_fbc->common.fn_flags & ZEND_ACC_PRIVATE + if ((priv_fbc->common.fn_flags & ZEND_ACC_PRIVATE) && priv_fbc->common.scope == scope) { fcc->function_handler = priv_fbc; } @@ -3096,7 +3096,7 @@ static zend_always_inline int zend_is_callable_check_func(int check_flags, zval if (fcc->object) { fcc->called_scope = fcc->object->ce; if (fcc->function_handler - && fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC) { + && (fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) { fcc->object = NULL; } } diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 6bd5a8716b2ce..af008c3628fa5 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -181,7 +181,7 @@ ZEND_METHOD(Closure, call) /* copied upon generator creation */ GC_DELREF(&closure->std); } else if (ZEND_USER_CODE(my_function.type) - && fci_cache.function_handler->common.fn_flags & ZEND_ACC_HEAP_RT_CACHE) { + && (fci_cache.function_handler->common.fn_flags & ZEND_ACC_HEAP_RT_CACHE)) { efree(ZEND_MAP_PTR(my_function.op_array.run_time_cache)); } } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 83c2573d791dc..86e169893ab3b 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2333,7 +2333,7 @@ void zend_emit_final_return(int return_one) /* {{{ */ zend_op *ret; zend_bool returns_reference = (CG(active_op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0; - if (CG(active_op_array)->fn_flags & ZEND_ACC_HAS_RETURN_TYPE + if ((CG(active_op_array)->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) && !(CG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR)) { zend_emit_return_type_check(NULL, CG(active_op_array)->arg_info - 1, 1); } @@ -4516,7 +4516,7 @@ void zend_compile_return(zend_ast *ast) /* {{{ */ } /* Generator return types are handled separately */ - if (!is_generator && CG(active_op_array)->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { + if (!is_generator && (CG(active_op_array)->fn_flags & ZEND_ACC_HAS_RETURN_TYPE)) { zend_emit_return_type_check( expr_ast ? &expr_node : NULL, CG(active_op_array)->arg_info - 1, 0); } @@ -5492,7 +5492,7 @@ ZEND_API void zend_set_function_arg_flags(zend_function *func) /* {{{ */ ZEND_SET_ARG_FLAG(func, i + 1, ZEND_ARG_SEND_MODE(&func->common.arg_info[i])); i++; } - if (UNEXPECTED(func->common.fn_flags & ZEND_ACC_VARIADIC && ZEND_ARG_SEND_MODE(&func->common.arg_info[i]))) { + if (UNEXPECTED((func->common.fn_flags & ZEND_ACC_VARIADIC) && ZEND_ARG_SEND_MODE(&func->common.arg_info[i]))) { uint32_t pass_by_reference = ZEND_ARG_SEND_MODE(&func->common.arg_info[i]); while (i < MAX_ARG_FLAG_NUM) { ZEND_SET_ARG_FLAG(func, i + 1, pass_by_reference); @@ -9339,7 +9339,7 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */ } /* Set isset fetch indicator here, opcache disallows runtime altering of the AST */ - if (ast->attr & ZEND_DIM_IS && ast->child[0]->kind == ZEND_AST_DIM) { + if ((ast->attr & ZEND_DIM_IS) && ast->child[0]->kind == ZEND_AST_DIM) { ast->child[0]->attr |= ZEND_DIM_IS; } diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index ce5411b0406bd..81a1b7b776b29 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -1156,7 +1156,7 @@ static zend_never_inline zend_function *zend_get_parent_private_method(zend_clas func = zend_hash_find(&scope->function_table, function_name); if (func != NULL) { fbc = Z_FUNC_P(func); - if (fbc->common.fn_flags & ZEND_ACC_PRIVATE + if ((fbc->common.fn_flags & ZEND_ACC_PRIVATE) && fbc->common.scope == scope) { return fbc; } diff --git a/ext/date/php_date.c b/ext/date/php_date.c index e71699ecbfa14..567e8ad044813 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -4374,17 +4374,17 @@ PHP_METHOD(DatePeriod, getRecurrences) static int check_id_allowed(char *id, zend_long what) /* {{{ */ { - if (what & PHP_DATE_TIMEZONE_GROUP_AFRICA && strncasecmp(id, "Africa/", 7) == 0) return 1; - if (what & PHP_DATE_TIMEZONE_GROUP_AMERICA && strncasecmp(id, "America/", 8) == 0) return 1; - if (what & PHP_DATE_TIMEZONE_GROUP_ANTARCTICA && strncasecmp(id, "Antarctica/", 11) == 0) return 1; - if (what & PHP_DATE_TIMEZONE_GROUP_ARCTIC && strncasecmp(id, "Arctic/", 7) == 0) return 1; - if (what & PHP_DATE_TIMEZONE_GROUP_ASIA && strncasecmp(id, "Asia/", 5) == 0) return 1; - if (what & PHP_DATE_TIMEZONE_GROUP_ATLANTIC && strncasecmp(id, "Atlantic/", 9) == 0) return 1; - if (what & PHP_DATE_TIMEZONE_GROUP_AUSTRALIA && strncasecmp(id, "Australia/", 10) == 0) return 1; - if (what & PHP_DATE_TIMEZONE_GROUP_EUROPE && strncasecmp(id, "Europe/", 7) == 0) return 1; - if (what & PHP_DATE_TIMEZONE_GROUP_INDIAN && strncasecmp(id, "Indian/", 7) == 0) return 1; - if (what & PHP_DATE_TIMEZONE_GROUP_PACIFIC && strncasecmp(id, "Pacific/", 8) == 0) return 1; - if (what & PHP_DATE_TIMEZONE_GROUP_UTC && strncasecmp(id, "UTC", 3) == 0) return 1; + if ((what & PHP_DATE_TIMEZONE_GROUP_AFRICA) && strncasecmp(id, "Africa/", 7) == 0) return 1; + if ((what & PHP_DATE_TIMEZONE_GROUP_AMERICA) && strncasecmp(id, "America/", 8) == 0) return 1; + if ((what & PHP_DATE_TIMEZONE_GROUP_ANTARCTICA) && strncasecmp(id, "Antarctica/", 11) == 0) return 1; + if ((what & PHP_DATE_TIMEZONE_GROUP_ARCTIC) && strncasecmp(id, "Arctic/", 7) == 0) return 1; + if ((what & PHP_DATE_TIMEZONE_GROUP_ASIA) && strncasecmp(id, "Asia/", 5) == 0) return 1; + if ((what & PHP_DATE_TIMEZONE_GROUP_ATLANTIC) && strncasecmp(id, "Atlantic/", 9) == 0) return 1; + if ((what & PHP_DATE_TIMEZONE_GROUP_AUSTRALIA) && strncasecmp(id, "Australia/", 10) == 0) return 1; + if ((what & PHP_DATE_TIMEZONE_GROUP_EUROPE) && strncasecmp(id, "Europe/", 7) == 0) return 1; + if ((what & PHP_DATE_TIMEZONE_GROUP_INDIAN) && strncasecmp(id, "Indian/", 7) == 0) return 1; + if ((what & PHP_DATE_TIMEZONE_GROUP_PACIFIC) && strncasecmp(id, "Pacific/", 8) == 0) return 1; + if ((what & PHP_DATE_TIMEZONE_GROUP_UTC) && strncasecmp(id, "UTC", 3) == 0) return 1; return 0; } /* }}} */ diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index e4ea0099c1492..e54f1dd8d4d7e 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -3485,7 +3485,7 @@ static int zend_ffi_validate_incomplete_type(zend_ffi_type *type, zend_bool allo } zend_ffi_throw_parser_error("Incomplete type at line %d", FFI_G(line)); return FAILURE; - } else if (!allow_incomplete_array && type->attr & ZEND_FFI_ATTR_INCOMPLETE_ARRAY) { + } else if (!allow_incomplete_array && (type->attr & ZEND_FFI_ATTR_INCOMPLETE_ARRAY)) { zend_ffi_throw_parser_error("'[]' not allowed at line %d", FFI_G(line)); return FAILURE; } else if (!FFI_G(allow_vla) && (type->attr & ZEND_FFI_ATTR_VLA)) { diff --git a/ext/mysqlnd/mysqlnd_connection.c b/ext/mysqlnd/mysqlnd_connection.c index c1b2926711a85..792412e587275 100644 --- a/ext/mysqlnd/mysqlnd_connection.c +++ b/ext/mysqlnd/mysqlnd_connection.c @@ -1439,7 +1439,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_server_version)(const MYSQLND_CONN_DATA * #define MARIA_DB_VERSION_HACK_PREFIX "5.5.5-" - if (conn->server_capabilities & CLIENT_PLUGIN_AUTH + if ((conn->server_capabilities & CLIENT_PLUGIN_AUTH) && !strncmp(p, MARIA_DB_VERSION_HACK_PREFIX, sizeof(MARIA_DB_VERSION_HACK_PREFIX)-1)) { p += sizeof(MARIA_DB_VERSION_HACK_PREFIX)-1; @@ -2000,24 +2000,24 @@ MYSQLND_METHOD(mysqlnd_conn_data, tx_rollback)(MYSQLND_CONN_DATA * conn) static void MYSQLND_METHOD(mysqlnd_conn_data, tx_cor_options_to_string)(const MYSQLND_CONN_DATA * const conn, smart_str * str, const unsigned int mode) { - if (mode & TRANS_COR_AND_CHAIN && !(mode & TRANS_COR_AND_NO_CHAIN)) { + if ((mode & TRANS_COR_AND_CHAIN) && !(mode & TRANS_COR_AND_NO_CHAIN)) { if (str->s && ZSTR_LEN(str->s)) { smart_str_appendl(str, " ", sizeof(" ") - 1); } smart_str_appendl(str, "AND CHAIN", sizeof("AND CHAIN") - 1); - } else if (mode & TRANS_COR_AND_NO_CHAIN && !(mode & TRANS_COR_AND_CHAIN)) { + } else if ((mode & TRANS_COR_AND_NO_CHAIN) && !(mode & TRANS_COR_AND_CHAIN)) { if (str->s && ZSTR_LEN(str->s)) { smart_str_appendl(str, " ", sizeof(" ") - 1); } smart_str_appendl(str, "AND NO CHAIN", sizeof("AND NO CHAIN") - 1); } - if (mode & TRANS_COR_RELEASE && !(mode & TRANS_COR_NO_RELEASE)) { + if ((mode & TRANS_COR_RELEASE) && !(mode & TRANS_COR_NO_RELEASE)) { if (str->s && ZSTR_LEN(str->s)) { smart_str_appendl(str, " ", sizeof(" ") - 1); } smart_str_appendl(str, "RELEASE", sizeof("RELEASE") - 1); - } else if (mode & TRANS_COR_NO_RELEASE && !(mode & TRANS_COR_RELEASE)) { + } else if ((mode & TRANS_COR_NO_RELEASE) && !(mode & TRANS_COR_RELEASE)) { if (str->s && ZSTR_LEN(str->s)) { smart_str_appendl(str, " ", sizeof(" ") - 1); } diff --git a/ext/mysqlnd/mysqlnd_debug.h b/ext/mysqlnd/mysqlnd_debug.h index 49d2f8426a713..79d53ad700d02 100644 --- a/ext/mysqlnd/mysqlnd_debug.h +++ b/ext/mysqlnd/mysqlnd_debug.h @@ -129,18 +129,18 @@ PHPAPI MYSQLND_DEBUG * mysqlnd_debug_init(const char * skip_functions[]); /* EMPTY */ ; /* shut compiler's mouth */ \ } \ do { \ - if (((dbg_obj1) && (dbg_obj1)->flags & MYSQLND_DEBUG_PROFILE_CALLS) || \ - ((dbg_obj2) && (dbg_obj2)->flags & MYSQLND_DEBUG_PROFILE_CALLS)) \ + if (((dbg_obj1) && ((dbg_obj1)->flags & MYSQLND_DEBUG_PROFILE_CALLS)) || \ + ((dbg_obj2) && ((dbg_obj2)->flags & MYSQLND_DEBUG_PROFILE_CALLS))) \ { \ DBG_PROFILE_START_TIME(); \ } \ } while (0); -#define DBG_LEAVE_EX2(dbg_obj1, dbg_obj2, leave) \ - do {\ +#define DBG_LEAVE_EX2(dbg_obj1, dbg_obj2, leave) \ + do { \ uint64_t this_call_duration = 0; \ - if (((dbg_obj1) && (dbg_obj1)->flags & MYSQLND_DEBUG_PROFILE_CALLS) || \ - ((dbg_obj2) && (dbg_obj2)->flags & MYSQLND_DEBUG_PROFILE_CALLS)) \ + if (((dbg_obj1) && ((dbg_obj1)->flags & MYSQLND_DEBUG_PROFILE_CALLS)) || \ + ((dbg_obj2) && ((dbg_obj2)->flags & MYSQLND_DEBUG_PROFILE_CALLS))) \ { \ DBG_PROFILE_END_TIME(this_call_duration); \ } \ diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index 10fabd59dacbf..7526c42ae6c16 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -1995,7 +1995,7 @@ php_mysqlnd_chg_user_read(MYSQLND_CONN_DATA * conn, void * _packet) packet->response_code = uint1korr(p); p++; - if (packet->header.size == 1 && buf[0] == EODATA_MARKER && packet->server_capabilities & CLIENT_SECURE_CONNECTION) { + if (packet->header.size == 1 && buf[0] == EODATA_MARKER && (packet->server_capabilities & CLIENT_SECURE_CONNECTION)) { /* We don't handle 3.23 authentication */ packet->server_asked_323_auth = TRUE; DBG_RETURN(FAIL); diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c index 4d15af9e4f325..b2d6dcf9e74d0 100644 --- a/ext/opcache/Optimizer/sccp.c +++ b/ext/opcache/Optimizer/sccp.c @@ -2258,7 +2258,7 @@ static int try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var, } else if (var->use_chain >= 0 || var->phi_use_chain != NULL) { if (value - && opline->result_type & (IS_VAR|IS_TMP_VAR) + && (opline->result_type & (IS_VAR|IS_TMP_VAR)) && opline->opcode != ZEND_QM_ASSIGN && opline->opcode != ZEND_ROPE_INIT && opline->opcode != ZEND_ROPE_ADD @@ -2288,7 +2288,7 @@ static int try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var, if (opline->opcode == ZEND_DO_ICALL) { removed_ops = remove_call(ctx, opline, ssa_op); } else if (opline->opcode == ZEND_TYPE_CHECK - && opline->op1_type & (IS_VAR|IS_TMP_VAR) + && (opline->op1_type & (IS_VAR|IS_TMP_VAR)) && !value_known(&ctx->values[ssa_op->op1_use])) { /* For TYPE_CHECK we may compute the result value without knowing the * operand, based on type inference information. Make sure the operand is diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index b095425cafd7a..8bdd52d906855 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -761,7 +761,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_ return 1; } - if (flags & PDO_FETCH_GROUP && stmt->fetch.column == -1) { + if ((flags & PDO_FETCH_GROUP) && stmt->fetch.column == -1) { colno = 1; } else { colno = stmt->fetch.column; diff --git a/ext/phar/stream.c b/ext/phar/stream.c index f3de4dde25249..bdc15683de783 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -318,7 +318,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha return NULL; } - if (!PHAR_G(cwd_init) && options & STREAM_OPEN_FOR_INCLUDE) { + if (!PHAR_G(cwd_init) && (options & STREAM_OPEN_FOR_INCLUDE)) { char *entry = idata->internal_file->filename, *cwd; PHAR_G(cwd_init) = 1; diff --git a/ext/phar/util.c b/ext/phar/util.c index 53982b0f85206..35322734d0992 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -1319,7 +1319,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, si return NULL; } - if (ssb.sb.st_mode & S_IFDIR && !dir) { + if ((ssb.sb.st_mode & S_IFDIR) && !dir) { efree(test); if (error) { spprintf(error, 4096, "phar error: path \"%s\" is a directory", path); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index d986f828f57b7..9903863391ffc 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -422,7 +422,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char zend_function *mptr; ZEND_HASH_FOREACH_PTR(&ce->function_table, mptr) { - if (mptr->common.fn_flags & ZEND_ACC_STATIC + if ((mptr->common.fn_flags & ZEND_ACC_STATIC) && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) { count_static_funcs++; @@ -436,7 +436,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char zend_function *mptr; ZEND_HASH_FOREACH_PTR(&ce->function_table, mptr) { - if (mptr->common.fn_flags & ZEND_ACC_STATIC + if ((mptr->common.fn_flags & ZEND_ACC_STATIC) && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) { smart_str_append_printf(str, "\n"); @@ -3499,7 +3499,7 @@ ZEND_METHOD(ReflectionMethod, isConstructor) /* we need to check if the ctor is the ctor of the class level we we * looking at since we might be looking at an inherited old style ctor * defined in base class. */ - RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_CTOR && intern->ce->constructor && intern->ce->constructor->common.scope == mptr->common.scope); + RETURN_BOOL((mptr->common.fn_flags & ZEND_ACC_CTOR) && intern->ce->constructor && intern->ce->constructor->common.scope == mptr->common.scope); } /* }}} */ diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index b11cfacc3c7fa..0462c46aa47cf 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -701,7 +701,7 @@ PHP_METHOD(SplDoublyLinkedList, setIteratorMode) intern = Z_SPLDLLIST_P(ZEND_THIS); - if (intern->flags & SPL_DLLIST_IT_FIX + if ((intern->flags & SPL_DLLIST_IT_FIX) && (intern->flags & SPL_DLLIST_IT_LIFO) != (value & SPL_DLLIST_IT_LIFO)) { zend_throw_exception(spl_ce_RuntimeException, "Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen", 0); RETURN_THROWS(); diff --git a/ext/spl/spl_functions.c b/ext/spl/spl_functions.c index 6a44ab3cfb00f..946f6e0ad9b0d 100644 --- a/ext/spl/spl_functions.c +++ b/ext/spl/spl_functions.c @@ -75,7 +75,7 @@ void spl_register_property( zend_class_entry * class_entry, char *prop_name, int /* {{{ spl_add_class_name */ void spl_add_class_name(zval *list, zend_class_entry *pce, int allow, int ce_flags) { - if (!allow || (allow > 0 && pce->ce_flags & ce_flags) || (allow < 0 && !(pce->ce_flags & ce_flags))) { + if (!allow || (allow > 0 && (pce->ce_flags & ce_flags)) || (allow < 0 && !(pce->ce_flags & ce_flags))) { zval *tmp; if ((tmp = zend_hash_find(Z_ARRVAL_P(list), pce->name)) == NULL) { diff --git a/ext/standard/array.c b/ext/standard/array.c index 1789dd52d248c..eda7ef589c996 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -4748,7 +4748,7 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int if (behavior == INTERSECT_NORMAL && data_compare_type == INTERSECT_COMP_DATA_USER) { BG(user_compare_fci) = *fci_data; BG(user_compare_fci_cache) = *fci_data_cache; - } else if (behavior & INTERSECT_ASSOC && key_compare_type == INTERSECT_COMP_KEY_USER) { + } else if ((behavior & INTERSECT_ASSOC) && key_compare_type == INTERSECT_COMP_KEY_USER) { BG(user_compare_fci) = *fci_key; BG(user_compare_fci_cache) = *fci_key_cache; } @@ -5155,7 +5155,7 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_ if (behavior == DIFF_NORMAL && data_compare_type == DIFF_COMP_DATA_USER) { BG(user_compare_fci) = *fci_data; BG(user_compare_fci_cache) = *fci_data_cache; - } else if (behavior & DIFF_ASSOC && key_compare_type == DIFF_COMP_KEY_USER) { + } else if ((behavior & DIFF_ASSOC) && key_compare_type == DIFF_COMP_KEY_USER) { BG(user_compare_fci) = *fci_key; BG(user_compare_fci_cache) = *fci_key_cache; } diff --git a/ext/standard/file.c b/ext/standard/file.c index 9f096ff772917..cdd6d767dbc69 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -621,7 +621,7 @@ PHP_FUNCTION(file_put_contents) RETURN_FALSE; } - if (flags & LOCK_EX && (!php_stream_supports_lock(stream) || php_stream_lock(stream, LOCK_EX))) { + if ((flags & LOCK_EX) && (!php_stream_supports_lock(stream) || php_stream_lock(stream, LOCK_EX))) { php_stream_close(stream); php_error_docref(NULL, E_WARNING, "Exclusive locks are not supported for this stream"); RETURN_FALSE; diff --git a/ext/standard/flock_compat.c b/ext/standard/flock_compat.c index ecf28d85130af..6751aedfc1990 100644 --- a/ext/standard/flock_compat.c +++ b/ext/standard/flock_compat.c @@ -58,7 +58,7 @@ PHPAPI int php_flock(int fd, int operation) ret = fcntl(fd, operation & LOCK_NB ? F_SETLK : F_SETLKW, &flck); - if (operation & LOCK_NB && ret == -1 && + if ((operation & LOCK_NB) && ret == -1 && (errno == EACCES || errno == EAGAIN)) errno = EWOULDBLOCK; diff --git a/main/main.c b/main/main.c index 5903c363fd857..d00915b026c35 100644 --- a/main/main.c +++ b/main/main.c @@ -1265,7 +1265,7 @@ static ZEND_COLD void php_error_cb(int orig_type, const char *error_filename, co } /* display/log the error if necessary */ - if (display && (EG(error_reporting) & type || (type & E_CORE)) + if (display && ((EG(error_reporting) & type) || (type & E_CORE)) && (PG(log_errors) || PG(display_errors) || (!module_initialized))) { char *error_type_str; int syslog_type_int = LOG_NOTICE; diff --git a/main/streams/memory.c b/main/streams/memory.c index 35be57d3c38f1..cd3a5cb9505ea 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -254,9 +254,9 @@ static int php_stream_memory_set_option(php_stream *stream, int option, int valu ms->fsize = newsize; return PHP_STREAM_OPTION_RETURN_OK; } - default: - return PHP_STREAM_OPTION_RETURN_NOTIMPL; } + + return PHP_STREAM_OPTION_RETURN_NOTIMPL; } /* }}} */ diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h index 98daa114a52ba..29c9ae28a6f55 100644 --- a/main/streams/php_stream_context.h +++ b/main/streams/php_stream_context.h @@ -100,7 +100,7 @@ END_EXTERN_C() (context)->notifier->mask |= PHP_STREAM_NOTIFIER_PROGRESS; \ php_stream_notify_progress((context), (sofar), (bmax)); } } while (0) -#define php_stream_notify_progress_increment(context, dsofar, dmax) do { if ((context) && (context)->notifier && (context)->notifier->mask & PHP_STREAM_NOTIFIER_PROGRESS) { \ +#define php_stream_notify_progress_increment(context, dsofar, dmax) do { if ((context) && (context)->notifier && ((context)->notifier->mask & PHP_STREAM_NOTIFIER_PROGRESS)) { \ (context)->notifier->progress += (dsofar); \ (context)->notifier->progress_max += (dmax); \ php_stream_notify_progress((context), (context)->notifier->progress, (context)->notifier->progress_max); } } while (0) diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index edde4121b8a50..39ba948d74c2e 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -903,6 +903,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void #endif } } + return PHP_STREAM_OPTION_RETURN_NOTIMPL; #ifdef PHP_WIN32 case PHP_STREAM_OPTION_PIPE_BLOCKING: diff --git a/main/streams/streams.c b/main/streams/streams.c index 9762fa90e8438..90475a8d90afe 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -245,7 +245,7 @@ PHPAPI void php_stream_wrapper_log_error(const php_stream_wrapper *wrapper, int vspprintf(&buffer, 0, fmt, args); va_end(args); - if (options & REPORT_ERRORS || wrapper == NULL) { + if ((options & REPORT_ERRORS) || wrapper == NULL) { php_error_docref(NULL, E_WARNING, "%s", buffer); efree(buffer); } else { @@ -703,7 +703,7 @@ PHPAPI ssize_t _php_stream_read(php_stream *stream, char *buf, size_t size) break; } - if (!stream->readfilters.head && (stream->flags & PHP_STREAM_FLAG_NO_BUFFER || stream->chunk_size == 1)) { + if (!stream->readfilters.head && ((stream->flags & PHP_STREAM_FLAG_NO_BUFFER) || stream->chunk_size == 1)) { toread = stream->ops->read(stream, buf, size); if (toread < 0) { /* Report an error if the read failed and we did not read any data @@ -2088,7 +2088,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod path_to_open = path; wrapper = php_stream_locate_url_wrapper(path, &path_to_open, options); - if (options & STREAM_USE_URL && (!wrapper || !wrapper->is_url)) { + if ((options & STREAM_USE_URL) && (!wrapper || !wrapper->is_url)) { php_error_docref(NULL, E_WARNING, "This function may only be used against URLs"); if (resolved_path) { zend_string_release_ex(resolved_path, 0); diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index 77b18fd2df6b8..b058e5beb4284 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -449,12 +449,11 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void #endif default: - return PHP_STREAM_OPTION_RETURN_NOTIMPL; + break; } - - default: - return PHP_STREAM_OPTION_RETURN_NOTIMPL; } + + return PHP_STREAM_OPTION_RETURN_NOTIMPL; } static int php_sockop_cast(php_stream *stream, int castas, void **ret) diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index b9c5aa523b38b..4a25455374c64 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -1833,7 +1833,7 @@ static int php_cli_server_client_read_request(php_cli_server_client *client, cha nbytes_consumed = php_http_parser_execute(&client->parser, &settings, buf, nbytes_read); if (nbytes_consumed != (size_t)nbytes_read) { if (php_cli_server_log_level >= PHP_CLI_SERVER_LOG_ERROR) { - if (buf[0] & 0x80 /* SSLv2 */ || buf[0] == 0x16 /* SSLv3/TLSv1 */) { + if ((buf[0] & 0x80) /* SSLv2 */ || buf[0] == 0x16 /* SSLv3/TLSv1 */) { *errstr = estrdup("Unsupported SSL request"); } else { *errstr = estrdup("Malformed HTTP request"); diff --git a/sapi/cli/php_http_parser.c b/sapi/cli/php_http_parser.c index 6d764b6c0dff0..bb1c4924a0d49 100644 --- a/sapi/cli/php_http_parser.c +++ b/sapi/cli/php_http_parser.c @@ -1315,7 +1315,7 @@ size_t php_http_parser_execute (php_http_parser *parser, nread = 0; - if (parser->flags & F_UPGRADE || parser->method == PHP_HTTP_CONNECT) { + if ((parser->flags & F_UPGRADE) || parser->method == PHP_HTTP_CONNECT) { parser->upgrade = 1; }