Skip to content
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

Remove redundant expression #776

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Remove redundant expression #776

wants to merge 1 commit into from

Conversation

AreaZR
Copy link
Contributor

@AreaZR AreaZR commented Feb 4, 2023

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.
@AreaZR
Copy link
Contributor Author

AreaZR commented Feb 4, 2023

@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