Skip to content

Commit

Permalink
Collaps unnecessary if-block.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikarus23 committed Aug 31, 2024
1 parent 2037619 commit 065743f
Showing 1 changed file with 12 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -588,33 +588,19 @@ private void writeBlock() {

// Write. There are some tags which report a successful write, although
// the write was not successful. Therefore, we try to write it using both keys.
if (sector == 0 && block == 0) {
// Write the manufacturer bock. This is only possible on gen2 tags.
if (keys[1] != null) {
resultKeyB = reader.writeBlock(sector, block,
Common.hex2Bytes(data),
keys[1], true);
}
if (keys[0] != null) {
resultKeyA = reader.writeBlock(sector, block,
Common.hex2Bytes(data),
keys[0], false);
}
} else {
// Normal block. Try key B first.
if (keys[1] != null) {
resultKeyB = reader.writeBlock(sector, block,
Common.hex2Bytes(data),
keys[1], true);
}
// Try to write with key A (if there is one).
if (keys[0] != null) {
resultKeyA = reader.writeBlock(sector, block,
Common.hex2Bytes(data),
keys[0], false);
}

// Try key B first.
if (keys[1] != null) {
resultKeyB = reader.writeBlock(sector, block,
Common.hex2Bytes(data),
keys[1], true);
}
// Try to write with key A (if there is one).
if (keys[0] != null) {
resultKeyA = reader.writeBlock(sector, block,
Common.hex2Bytes(data),
keys[0], false);
}

reader.close();
if (resultKeyA == 0 || resultKeyB == 0) {
result = 0;
Expand Down

0 comments on commit 065743f

Please sign in to comment.