Skip to content

[gardening] "if (foo == false)" → "if (!foo)" #1405

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
Feb 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions stdlib/public/runtime/CygwinPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int swift::_swift_dl_iterate_phdr(int (*Callback)(struct dl_phdr_info *info,
BOOL ret = EnumProcessModules(procHandle, modules.data(),
modules.size() * sizeof(HMODULE), &neededSize);

if (ret == FALSE) {
if (!ret) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's FALSE defined as on Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I naïvely assumed 0 but I guess we should be on the safe side and check with the Windows/Cygwin guru @tinysun212 :-)

@tinysun212, do you have time to review? That would be appreciated! :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

#define FALSE 0
#define TRUE 1

They are defined at /usr/include/w32api/ntdef.h in Cygwin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tinysun212 Thank you! 👍

swift::fatalError(/* flags = */ 0, "EnumProcessModules() failed");
return 0;
}
Expand All @@ -58,7 +58,7 @@ int swift::_swift_dl_iterate_phdr(int (*Callback)(struct dl_phdr_info *info,
modules.size() * sizeof(HMODULE), &neededSize);
}

if (ret == FALSE) {
if (!ret) {
swift::fatalError(/* flags = */ 0, "EnumProcessModules() failed");
return 0;
}
Expand Down Expand Up @@ -95,7 +95,7 @@ uint8_t *swift::_swift_getSectionDataPE(void *handle, const char *sectionName,

bool assert1 =
peStart[ntHeadersOffset] == 'P' && peStart[ntHeadersOffset + 1] == 'E';
if (assert1 == false) {
if (!assert1) {
swift::fatalError(/* flags = */ 0, "_swift_getSectionDataPE()'s finding PE failed");
}

Expand Down