Skip to content

Remove redundant expression#776

Open
AZero13 wants to merge 1 commit into
swiftlang:mainfrom
AZero13:redundant
Open

Remove redundant expression#776
AZero13 wants to merge 1 commit into
swiftlang:mainfrom
AZero13:redundant

Conversation

@AZero13

@AZero13 AZero13 commented Feb 4, 2023

Copy link
Copy Markdown
Contributor

This is either a bug-causing expression, or a redundant statement of logic.

Consider the following logic, but applied on the bit-level: Here is a tautology for every bit: A ^ -B -> A.

This means, A & -B requires A must be 1 for it to stay.

!(pp & ~_PTHREAD_PRIORITY_FLAGS_MASK) being true means every bit that is a 1 in pp is a bit that will yield 0 when XORed with _PTHREAD_PRIORITY_FLAGS_MASK.

Because of this, &= _PTHREAD_PRIORITY_FLAGS_MASK has no effect. Therefore, !(pp & ~_PTHREAD_PRIORITY_FLAGS_MASK) is redundant. However, because the comment mentions an and, there is the possibility the entire conditional may have been incorrectly written, causing bugs.

This is either a bug-causing expression, or a redundant statement of logic.

Consider the following logic, but applied on the bit-level:
Here is a tautology for every bit: A ^ -B -> A.

This means, A & -B requires A must be 1 for it to stay.

!(pp & ~_PTHREAD_PRIORITY_FLAGS_MASK) being true means every bit that is a 1 in pp is a bit that will yield 0 when XORed with _PTHREAD_PRIORITY_FLAGS_MASK.

Because of this, &= _PTHREAD_PRIORITY_FLAGS_MASK has no effect. Therefore, !(pp & ~_PTHREAD_PRIORITY_FLAGS_MASK) is redundant. However, because the comment mentions an and, there is the possibility the entire conditional may have been incorrectly written, causing bugs.
@AZero13

AZero13 commented Feb 4, 2023

Copy link
Copy Markdown
Contributor Author

@compnerd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant