Skip to content

GH-131296: fix clang-cl parentheses warnings on Windows #131905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025

Conversation

chris-eibl
Copy link
Member

@chris-eibl chris-eibl commented Mar 30, 2025

I think this is a skip news?

This might seem unneeded, but in the Linux code base, the same warning levels are active, but do not fire.
IMHO, it is better to have these warnings active in the Windows code base, too, and fix them.

Every mainstream compiler warns on this suspicious-looking code.

@@ -6111,7 +6111,7 @@ _ssl_enum_certificates_impl(PyObject *module, const char *store_name)
return PyErr_SetFromWindowsErr(GetLastError());
}

while (pCertCtx = CertEnumCertificatesInStore(hCollectionStore, pCertCtx)) {
while ((pCertCtx = CertEnumCertificatesInStore(hCollectionStore, pCertCtx))) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix warning : using the result of an assignment as a condition without parentheses [-Wparentheses].

@@ -6210,7 +6210,7 @@ _ssl_enum_crls_impl(PyObject *module, const char *store_name)
return PyErr_SetFromWindowsErr(GetLastError());
}

while (pCrlCtx = CertEnumCRLsInStore(hCollectionStore, pCrlCtx)) {
while ((pCrlCtx = CertEnumCRLsInStore(hCollectionStore, pCrlCtx))) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix warning : using the result of an assignment as a condition without parentheses [-Wparentheses].

@@ -5372,7 +5372,7 @@ _testFileExistsByName(LPCWSTR path, BOOL followLinks)
sizeof(info)))
{
if (!(info.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) ||
!followLinks && IsReparseTagNameSurrogate(info.ReparseTag))
(!followLinks && IsReparseTagNameSurrogate(info.ReparseTag)))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix warning : '&&' within '||' [-Wlogical-op-parentheses].

@@ -2760,7 +2760,7 @@ process(int argc, wchar_t ** argv)
// We searched earlier, so if we didn't find anything, now we react
exitCode = searchExitCode;
// If none found, and if permitted, install it
if (exitCode == RC_NO_PYTHON && isEnvVarSet(L"PYLAUNCHER_ALLOW_INSTALL") ||
if (((exitCode == RC_NO_PYTHON) && isEnvVarSet(L"PYLAUNCHER_ALLOW_INSTALL")) ||
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix warning : '&&' within '||' [-Wlogical-op-parentheses].

@chris-eibl chris-eibl changed the title GH-131296: fix "parentheses" clang-cl warnings on Windows GH-131296: fix clang-cl parentheses warnings on Windows Mar 30, 2025
@zooba
Copy link
Member

zooba commented Mar 31, 2025

Eh, personally I think these make the code uglier, but there are so few changes that we may as well. Consistency between platforms is worth it.

@zooba zooba merged commit 7cbcb6e into python:main Mar 31, 2025
45 checks passed
@chris-eibl chris-eibl deleted the fix_clangcl_parentheses branch March 31, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants