Skip to content

Static analysis fix: replace 0 and NULL with nullptr #738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/yaml-cpp/binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class YAML_CPP_API Binary {
rhs.clear();
rhs.resize(m_unownedSize);
std::copy(m_unownedData, m_unownedData + m_unownedSize, rhs.begin());
m_unownedData = 0;
m_unownedData = nullptr;
m_unownedSize = 0;
} else {
m_data.swap(rhs);
Expand Down
4 changes: 2 additions & 2 deletions include/yaml-cpp/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ inline const std::string KEY_NOT_FOUND_WITH_KEY(

template <typename T>
inline const std::string BAD_SUBSCRIPT_WITH_KEY(
const T&, typename disable_if<is_numeric<T>>::type* = 0) {
const T&, typename disable_if<is_numeric<T>>::type* = nullptr) {
return BAD_SUBSCRIPT;
}

Expand All @@ -129,7 +129,7 @@ inline const std::string BAD_SUBSCRIPT_WITH_KEY(const std::string& key) {

template <typename T>
inline const std::string BAD_SUBSCRIPT_WITH_KEY(
const T& key, typename enable_if<is_numeric<T>>::type* = 0) {
const T& key, typename enable_if<is_numeric<T>>::type* = nullptr) {
std::stringstream stream;
stream << BAD_SUBSCRIPT << " (key: \"" << key << "\")";
return stream.str();
Expand Down
14 changes: 7 additions & 7 deletions include/yaml-cpp/node/detail/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ template <typename Key, typename Enable = void>
struct get_idx {
static node* get(const std::vector<node*>& /* sequence */,
const Key& /* key */, shared_memory_holder /* pMemory */) {
return 0;
return nullptr;
}
};

Expand All @@ -27,7 +27,7 @@ struct get_idx<Key,
!std::is_same<Key, bool>::value>::type> {
static node* get(const std::vector<node*>& sequence, const Key& key,
shared_memory_holder /* pMemory */) {
return key < sequence.size() ? sequence[key] : 0;
return key < sequence.size() ? sequence[key] : nullptr;
}

static node* get(std::vector<node*>& sequence, const Key& key,
Expand All @@ -46,13 +46,13 @@ struct get_idx<Key, typename std::enable_if<std::is_signed<Key>::value>::type> {
shared_memory_holder pMemory) {
return key >= 0 ? get_idx<std::size_t>::get(
sequence, static_cast<std::size_t>(key), pMemory)
: 0;
: nullptr;
}
static node* get(std::vector<node*>& sequence, const Key& key,
shared_memory_holder pMemory) {
return key >= 0 ? get_idx<std::size_t>::get(
sequence, static_cast<std::size_t>(key), pMemory)
: 0;
: nullptr;
}
};

Expand Down Expand Up @@ -109,11 +109,11 @@ inline node* node_data::get(const Key& key,
break;
case NodeType::Undefined:
case NodeType::Null:
return NULL;
return nullptr;
case NodeType::Sequence:
if (node* pNode = get_idx<Key>::get(m_sequence, key, pMemory))
return pNode;
return NULL;
return nullptr;
case NodeType::Scalar:
throw BadSubscript(key);
}
Expand All @@ -124,7 +124,7 @@ inline node* node_data::get(const Key& key,
}
}

return NULL;
return nullptr;
}

template <typename Key>
Expand Down
4 changes: 2 additions & 2 deletions include/yaml-cpp/node/detail/node_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ template <typename V>
struct node_iterator_value : public std::pair<V*, V*> {
typedef std::pair<V*, V*> kv;

node_iterator_value() : kv(), pNode(0) {}
node_iterator_value() : kv(), pNode(nullptr) {}
explicit node_iterator_value(V& rhs) : kv(), pNode(&rhs) {}
explicit node_iterator_value(V& key, V& value) : kv(&key, &value), pNode(0) {}
explicit node_iterator_value(V& key, V& value) : kv(&key, &value), pNode(nullptr) {}

V& operator*() const { return *pNode; }
V& operator->() const { return *pNode; }
Expand Down
2 changes: 1 addition & 1 deletion include/yaml-cpp/node/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ inline Node::Node(Zombie)
: m_isValid(false), m_invalidKey{}, m_pMemory{}, m_pNode(nullptr) {}

inline Node::Node(Zombie, const std::string& key)
: m_isValid(false), m_invalidKey(key), m_pMemory{}, m_pNode(NULL) {}
: m_isValid(false), m_invalidKey(key), m_pMemory{}, m_pNode(nullptr) {}

inline Node::Node(detail::node& node, detail::shared_memory_holder pMemory)
: m_isValid(true), m_invalidKey{}, m_pMemory(pMemory), m_pNode(&node) {}
Expand Down
2 changes: 1 addition & 1 deletion include/yaml-cpp/ostream_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class YAML_CPP_API ostream_wrapper {

const char* str() const {
if (m_pStream) {
return 0;
return nullptr;
} else {
m_buffer[m_pos] = '\0';
return &m_buffer[0];
Expand Down