Skip to content

Commit

Permalink
Use nullptr instead of NULL
Browse files Browse the repository at this point in the history
Signed-off-by: Szczepan Zalega <[email protected]>
  • Loading branch information
szszszsz committed Mar 11, 2017
1 parent 2dec896 commit 55745fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion NitrokeyManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ namespace nitrokey{

shared_ptr <NitrokeyManager> NitrokeyManager::_instance = nullptr;

NitrokeyManager::NitrokeyManager() {
NitrokeyManager::NitrokeyManager() : device(nullptr)
{
set_debug(true);
}
NitrokeyManager::~NitrokeyManager() {
Expand Down
14 changes: 7 additions & 7 deletions device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Device::Device(const uint16_t vid, const uint16_t pid, const DeviceModel model,
m_retry_sending_count(3),
m_retry_receiving_count(retry_receiving_count),
m_retry_timeout(retry_timeout),
mp_devhandle(NULL),
mp_devhandle(nullptr),
last_command_status(0),
m_model(model),
m_send_receive_delay(send_receive_delay)
Expand All @@ -34,7 +34,7 @@ bool Device::disconnect() {

if(mp_devhandle == nullptr) return false;
hid_close(mp_devhandle);
mp_devhandle = NULL;
mp_devhandle = nullptr;
hid_exit();
return true;
}
Expand All @@ -43,15 +43,15 @@ bool Device::connect() {
Log::instance()(__PRETTY_FUNCTION__, Loglevel::DEBUG_L2);

// hid_init(); // done automatically on hid_open
mp_devhandle = hid_open(m_vid, m_pid, NULL);
return mp_devhandle != NULL;
mp_devhandle = hid_open(m_vid, m_pid, nullptr);
return mp_devhandle != nullptr;
}

int Device::send(const void *packet) {
std::lock_guard<std::mutex> lock(mex_dev_com);
Log::instance()(__PRETTY_FUNCTION__, Loglevel::DEBUG_L2);

if (mp_devhandle == NULL)
if (mp_devhandle == nullptr)
throw std::runtime_error("Attempted HID send on an invalid descriptor."); //TODO migrate except to library_error

return (hid_send_feature_report(
Expand All @@ -65,7 +65,7 @@ int Device::recv(void *packet) {

Log::instance()(__PRETTY_FUNCTION__, Loglevel::DEBUG_L2);

if (mp_devhandle == NULL)
if (mp_devhandle == nullptr)
throw std::runtime_error("Attempted HID receive on an invalid descriptor."); //TODO migrate except to library_error

// FIXME extract error handling and repeating to parent function in
Expand All @@ -76,7 +76,7 @@ int Device::recv(void *packet) {

// FIXME handle getting libhid error message somewhere else
auto pwherr = hid_error(mp_devhandle);
std::wstring wherr = (pwherr != NULL) ? pwherr : L"No error message";
std::wstring wherr = (pwherr != nullptr) ? pwherr : L"No error message";
std::string herr(wherr.begin(), wherr.end());
Log::instance()(std::string("libhid error message: ") + herr,
Loglevel::DEBUG_L2);
Expand Down

0 comments on commit 55745fc

Please sign in to comment.