diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2020-06-13 18:55:34 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2020-06-13 18:55:34 +0200 |
commit | a3fd24ff87eeae3d320e3ee48f1c6e1b9ba0a783 (patch) | |
tree | 338bdfdcb82f4bdf3ebf82593f4d70090b190d9b | |
parent | 2f1c76bf82619e0809a41a1df4fe0e26c6315270 (diff) | |
download | libnitrokey-a3fd24ff87eeae3d320e3ee48f1c6e1b9ba0a783.tar.gz libnitrokey-a3fd24ff87eeae3d320e3ee48f1c6e1b9ba0a783.tar.bz2 |
Invert if condition for readability
-rw-r--r-- | device.cc | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -209,16 +209,17 @@ std::vector<DeviceInfo> Device::enumerate(){ auto pInfo_ = pInfo; std::vector<DeviceInfo> res; while (pInfo != nullptr){ - if (pInfo->path != nullptr && pInfo->serial_number != nullptr) { - auto deviceModel = product_id_to_model(pInfo->product_id); - if (deviceModel.has_value()) { - std::string path(pInfo->path); - std::wstring serialNumberW(pInfo->serial_number); - std::wstring_convert<std::codecvt_utf8<wchar_t>> converter; - std::string serialNumber = converter.to_bytes(serialNumberW); - DeviceInfo info = { deviceModel.value(), path, serialNumber }; - res.push_back(info); - } + if (pInfo->path == nullptr || pInfo->serial_number == nullptr) { + continue; + } + auto deviceModel = product_id_to_model(pInfo->product_id); + if (deviceModel.has_value()) { + std::string path(pInfo->path); + std::wstring serialNumberW(pInfo->serial_number); + std::wstring_convert<std::codecvt_utf8<wchar_t>> converter; + std::string serialNumber = converter.to_bytes(serialNumberW); + DeviceInfo info = {deviceModel.value(), path, serialNumber}; + res.push_back(info); } pInfo = pInfo->next; } |