Improve readability and type-safety

Use nullptr instead of 0 or NULL to initialize a null pointer. In some
cases, readability was enhanced by replacing 0 with more meaningful
values according to the type of the pointer being initialized.
This commit is contained in:
Gianluca Recchia
2018-10-28 15:47:24 +01:00
parent 7208635502
commit 896a66e6d8
22 changed files with 47 additions and 47 deletions

View File

@@ -37,8 +37,8 @@
#define m_ykds (static_cast<YK_STATUS*>(m_ykds_void))
YubiKey::YubiKey()
: m_yk_void(NULL)
, m_ykds_void(NULL)
: m_yk_void(nullptr)
, m_ykds_void(nullptr)
, m_mutex(QMutex::Recursive)
{
}
@@ -59,7 +59,7 @@ bool YubiKey::init()
m_mutex.lock();
// previously initialized
if (m_yk != NULL && m_ykds != NULL) {
if (m_yk != nullptr && m_ykds != nullptr) {
if (yk_get_status(m_yk, m_ykds)) {
// Still connected
@@ -78,15 +78,15 @@ bool YubiKey::init()
// TODO: handle multiple attached hardware devices
m_yk_void = static_cast<void*>(yk_open_first_key());
if (m_yk == NULL) {
if (m_yk == nullptr) {
m_mutex.unlock();
return false;
}
m_ykds_void = static_cast<void*>(ykds_alloc());
if (m_ykds == NULL) {
if (m_ykds == nullptr) {
yk_close_key(m_yk);
m_yk_void = NULL;
m_yk_void = nullptr;
m_mutex.unlock();
return false;
}
@@ -101,12 +101,12 @@ bool YubiKey::deinit()
if (m_yk) {
yk_close_key(m_yk);
m_yk_void = NULL;
m_yk_void = nullptr;
}
if (m_ykds) {
ykds_free(m_ykds);
m_ykds_void = NULL;
m_ykds_void = nullptr;
}
m_mutex.unlock();