Skip to content

Commit 107bd08

Browse files
authored
Fix Clang style nits (GH-17685)
This addresses all `-Wlogical-op-parentheses` and `-Wmissing-braces` warnings across the whole code base (all Windows specific code).
1 parent dc7161c commit 107bd08

File tree

10 files changed

+12
-13
lines changed

10 files changed

+12
-13
lines changed

Zend/zend_hrtime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void zend_startup_hrtime(void);
8383
static zend_always_inline zend_hrtime_t zend_hrtime(void)
8484
{
8585
#if ZEND_HRTIME_PLATFORM_WINDOWS
86-
LARGE_INTEGER lt = {0};
86+
LARGE_INTEGER lt = {{0}};
8787
QueryPerformanceCounter(&lt);
8888
return (zend_hrtime_t)((zend_hrtime_t)lt.QuadPart * zend_hrtime_timer_scale);
8989
#elif ZEND_HRTIME_PLATFORM_APPLE_GETTIME_NSEC

ext/opcache/zend_file_cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
# define LOCK_UN 2
7676
static int zend_file_cache_flock(int fd, int op)
7777
{
78-
OVERLAPPED offset = {0,0,0,0,NULL};
78+
OVERLAPPED offset = {0, 0, {{0}}, NULL};
7979
if (op == LOCK_EX) {
8080
if (LockFileEx((HANDLE)_get_osfhandle(fd),
8181
LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 0, &offset) == TRUE) {

ext/openssl/xp_ssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ static int php_openssl_win_cert_verify_callback(X509_STORE_CTX *x509_store_ctx,
758758
}
759759

760760
{ /* Then verify it against a policy */
761-
SSL_EXTRA_CERT_CHAIN_POLICY_PARA ssl_policy_params = {sizeof(SSL_EXTRA_CERT_CHAIN_POLICY_PARA)};
761+
SSL_EXTRA_CERT_CHAIN_POLICY_PARA ssl_policy_params = {{sizeof(SSL_EXTRA_CERT_CHAIN_POLICY_PARA)}};
762762
CERT_CHAIN_POLICY_PARA chain_policy_params = {sizeof(CERT_CHAIN_POLICY_PARA)};
763763
CERT_CHAIN_POLICY_STATUS chain_policy_status = {sizeof(CERT_CHAIN_POLICY_STATUS)};
764764
BOOL verify_result;

ext/standard/basic_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ PHP_FUNCTION(putenv)
807807
valw = php_win32_cp_any_to_w(value);
808808
}
809809
/* valw may be NULL, but the failed conversion still needs to be checked. */
810-
if (!keyw || !valw && value) {
810+
if (!keyw || (!valw && value)) {
811811
tsrm_env_unlock();
812812
free(pe.putenv_string);
813813
zend_string_release(pe.key);

ext/standard/flock_compat.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ PHPAPI int php_flock(int fd, int operation)
104104
{
105105
HANDLE hdl = (HANDLE) _get_osfhandle(fd);
106106
DWORD low = 0xFFFFFFFF, high = 0xFFFFFFFF;
107-
OVERLAPPED offset =
108-
{0, 0, 0, 0, NULL};
107+
OVERLAPPED offset = {0, 0, {{0}}, NULL};
109108
DWORD err;
110109

111110
if (INVALID_HANDLE_VALUE == hdl) {

main/fopen_wrappers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ PHPAPI zend_string *php_resolve_path(const char *filename, size_t filename_lengt
531531
IS_ABSOLUTE_PATH doesn't care about this path form till now. It
532532
might be a big thing to extend, thus just a local handling for
533533
now. */
534-
filename_length >=2 && IS_SLASH(filename[0]) && !IS_SLASH(filename[1]) ||
534+
(filename_length >=2 && IS_SLASH(filename[0]) && !IS_SLASH(filename[1])) ||
535535
#endif
536536
!path ||
537537
!*path) {

sapi/cli/php_cli.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,9 @@ static int do_cli(int argc, char **argv) /* {{{ */
840840
is essential to mitigate buggy console info. */
841841
interactive = php_win32_console_is_own() &&
842842
!(script_file ||
843-
argc > php_optind && context.mode != PHP_CLI_MODE_CLI_DIRECT &&
843+
(argc > php_optind && context.mode != PHP_CLI_MODE_CLI_DIRECT &&
844844
context.mode != PHP_CLI_MODE_PROCESS_STDIN &&
845-
strcmp(argv[php_optind-1],"--")
845+
strcmp(argv[php_optind-1],"--"))
846846
);
847847
}
848848
#endif

win32/fnmatch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ PHPAPI int fnmatch(const char *pattern, const char *string, int flags)
137137
tolower((unsigned char)*string)))
138138
;
139139
else if ((flags & FNM_PREFIX_DIRS) && *string == EOS &&
140-
(c == '/' && string != stringstart ||
141-
string == stringstart+1 && *stringstart == '/') )
140+
((c == '/' && string != stringstart) ||
141+
(string == stringstart+1 && *stringstart == '/')))
142142
return (0);
143143
else
144144
return (FNM_NOMATCH);

win32/readdir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ DIR *opendir(const char *dir)
5959
wcscpy(filespecw, resolvedw);
6060
index = resolvedw_len - 1;
6161
}
62-
if (index >= 0 && filespecw[index] == L'/' || index == 0 && filespecw[index] == L'\\')
62+
if ((index >= 0 && filespecw[index] == L'/') || (index == 0 && filespecw[index] == L'\\'))
6363
filespecw[index] = L'\0';
6464
wcscat(filespecw, L"\\*");
6565

win32/winutil.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ static zend_always_inline BOOL is_compatible(HMODULE handle, BOOL is_smaller, ch
459459
This check is to be extended as new VS versions come out. */
460460
DWORD core_minor = (DWORD)(PHP_LINKER_MINOR/10);
461461
DWORD comp_minor = (DWORD)(minor/10);
462-
if (14 == major && (is_smaller ? core_minor < comp_minor : core_minor > comp_minor) || PHP_LINKER_MAJOR != major)
462+
if ((14 == major && (is_smaller ? core_minor < comp_minor : core_minor > comp_minor)) || PHP_LINKER_MAJOR != major)
463463
#else
464464
if (PHP_LINKER_MAJOR != major)
465465
#endif

0 commit comments

Comments
 (0)