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

Fixing if condition bug! #13

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

Conversation

chipjarred
Copy link

@chipjarred chipjarred commented May 10, 2021

In driver-gekko.c, the right side of an || expression always evaluated to false because it was testing that the same byte is simultaneously equal to four different values, which is logically impossible without being volatile (and if even if it were volatile it would almost certainly still be a bug).

Instead, I believe the intention was to work like the left-hand expression, which tests four consecutive bytes. I've changed it to do that.

So I changed it from this

case MINER_OPEN_CORE:
    if ((info->rx[0] == 0x72 && info->rx[1] == 0x03 && info->rx[2] == 0xEA && info->rx[3] == 0x83) ||
        (info->rx[0] == 0xE1 && info->rx[0] == 0x6B && info->rx[0] == 0xF8 && info->rx[0] == 0x09)) {
        //open core nonces = healthy chips.
        info->zero_check++;
    }
    break;

to this

case MINER_OPEN_CORE:
    if ((info->rx[0] == 0x72 && info->rx[1] == 0x03 && info->rx[2] == 0xEA && info->rx[3] == 0x83) ||
        (info->rx[0] == 0xE1 && info->rx[1] == 0x6B && info->rx[2] == 0xF8 && info->rx[3] == 0x09)) {
        //open core nonces = healthy chips.
        info->zero_check++;
    }
    break;

The right side of an `||` expression always evaluated to false because it was testing that the same byte is simultaneously equal to four different values, which is logically impossible without being `volatile` (and if even if it were `volatile` it would almost certainly still be a bug).

Instead, I believe the intention was to work like the left-hand expression, which tests four consecutive bytes. I've changed it to do that.
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