
Unreachable code
public void testSignSHA256CompleteEvenHeight2() {
....
int height = 10;
....
for (int i = 0; i < (1 << height); i++) {
byte[] signature = xmss.sign(new byte[1024]);
switch (i) {
case 0x005b:
assertEquals(signatures[0], Hex.toHexString(signature));
break;
case 0x0822:
assertEquals(signatures[1], Hex.toHexString(signature));
break;
....
}
}
}
V6019 Unreachable code detected. It is possible that an error is present. XMSSTest.java(170)
The value of the height variable in the method does not change, so the icounter in the for loop can’t be greater than 1024 (1 << 10). However, in the switch statement, the second case checks i for the value 0x0822 (2082). Obviously, the signatures[1] byte will never be checked.
Since this is the code of the test method, there is nothing wrong here. Developers just need to pay attention to the fact that one of bytes is never tested.
Please click here to see more bugs from this project.