Skip to content

Fixing if condition bug!#13

Open
chipjarred wants to merge 1 commit intovthoang:masterfrom
chipjarred:master
Open

Fixing if condition bug!#13
chipjarred wants to merge 1 commit intovthoang:masterfrom
chipjarred:master

Conversation

@chipjarred
Copy link
Copy Markdown

@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