diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-10-18 15:36:54 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-10-19 16:40:25 +0200 |
commit | b53d6455d1c7dfd24ec2cbb18d5e943c0472d34e (patch) | |
tree | 31c8110ad9f9e94c10797831be5312245304366f /include | |
parent | f9cc44df7e2882557e37cfb1e0ebe6d779d5eeb5 (diff) | |
download | libnitrokey-b53d6455d1c7dfd24ec2cbb18d5e943c0472d34e.tar.gz libnitrokey-b53d6455d1c7dfd24ec2cbb18d5e943c0472d34e.tar.bz2 |
Code refactoring: replacing magic numbers
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/device_proto.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/include/device_proto.h b/include/device_proto.h index 128eca8..6b06a16 100644 --- a/include/device_proto.h +++ b/include/device_proto.h @@ -264,8 +264,9 @@ namespace nitrokey { //SENDPASSWORD gives wrong CRC , for now rely on !=0 (TODO report) // if (resp.device_status == 0 && resp.last_command_crc == outp.crc && resp.isCRCcorrect()) break; - if (resp.device_status == 0 && resp.last_command_crc == outp.crc && resp.isValid()) break; - if (resp.device_status == 1) { + if (resp.device_status == static_cast<uint8_t>(stick10::device_status::ok) && + resp.last_command_crc == outp.crc && resp.isValid()) break; + if (resp.device_status == static_cast<uint8_t>(stick10::device_status::busy)) { receiving_retry_counter++; Log::instance()("Status busy, not decresing receiving_retry_counter counter: " + std::to_string(receiving_retry_counter), Loglevel::DEBUG_L2); @@ -307,7 +308,7 @@ namespace nitrokey { if (receiving_retry_counter <= 0) throw std::runtime_error( "Maximum receiving_retry_counter count reached for receiving response from the device!"); - if (resp.last_command_status != 0) + if (resp.last_command_status != static_cast<uint8_t>(stick10::command_status::ok)) throw CommandFailedException(resp.command_id, resp.last_command_status); |