diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-04-04 15:06:57 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-04-04 19:49:50 +0200 |
commit | f8ab79e68af20e18e1d868b64d6dfd0c429bc554 (patch) | |
tree | a9d2df2e2df939c189135b1c36a01e06b37b80b2 /core/templates | |
parent | 53317bbe146dd19a919685df8d846c55568daba1 (diff) |
Zero initialize all pointer class and struct members
This prevents the pitfall of UB when checking if they have been
assigned something valid by comparing to nullptr.
Diffstat (limited to 'core/templates')
-rw-r--r-- | core/templates/command_queue_mt.h | 2 | ||||
-rw-r--r-- | core/templates/map.h | 6 | ||||
-rw-r--r-- | core/templates/oa_hash_map.h | 2 | ||||
-rw-r--r-- | core/templates/safe_list.h | 8 | ||||
-rw-r--r-- | core/templates/self_list.h | 2 | ||||
-rw-r--r-- | core/templates/set.h | 4 | ||||
-rw-r--r-- | core/templates/thread_work_pool.h | 2 |
7 files changed, 13 insertions, 13 deletions
diff --git a/core/templates/command_queue_mt.h b/core/templates/command_queue_mt.h index 1ecb81c2a2..0aa1cfd541 100644 --- a/core/templates/command_queue_mt.h +++ b/core/templates/command_queue_mt.h @@ -311,7 +311,7 @@ class CommandQueueMT { }; struct SyncCommand : public CommandBase { - SyncSemaphore *sync_sem; + SyncSemaphore *sync_sem = nullptr; virtual void post() { sync_sem->sem.post(); diff --git a/core/templates/map.h b/core/templates/map.h index f228640a1e..c54da1dc03 100644 --- a/core/templates/map.h +++ b/core/templates/map.h @@ -178,7 +178,7 @@ public: private: struct _Data { Element *_root = nullptr; - Element *_nil; + Element *_nil = nullptr; int size_cache = 0; _FORCE_INLINE_ _Data() { @@ -344,7 +344,7 @@ private: void _insert_rb_fix(Element *p_new_node) { Element *node = p_new_node; Element *nparent = node->parent; - Element *ngrand_parent; + Element *ngrand_parent = nullptr; while (nparent->color == RED) { ngrand_parent = nparent->parent; @@ -500,7 +500,7 @@ private: Element *rp = ((p_node->left == _data._nil) || (p_node->right == _data._nil)) ? p_node : p_node->_next; Element *node = (rp->left == _data._nil) ? rp->right : rp->left; - Element *sibling; + Element *sibling = nullptr; if (rp == rp->parent->left) { rp->parent->left = node; sibling = rp->parent->right; diff --git a/core/templates/oa_hash_map.h b/core/templates/oa_hash_map.h index 4e712fccf2..e4d9323c45 100644 --- a/core/templates/oa_hash_map.h +++ b/core/templates/oa_hash_map.h @@ -306,7 +306,7 @@ public: bool valid; const TKey *key; - TValue *value; + TValue *value = nullptr; private: uint32_t pos; diff --git a/core/templates/safe_list.h b/core/templates/safe_list.h index 53fc3fe5f9..ae31525dd0 100644 --- a/core/templates/safe_list.h +++ b/core/templates/safe_list.h @@ -75,8 +75,8 @@ public: class Iterator { friend class SafeList; - SafeListNode *cursor; - SafeList *list; + SafeListNode *cursor = nullptr; + SafeList *list = nullptr; Iterator(SafeListNode *p_cursor, SafeList *p_list) : cursor(p_cursor), list(p_list) { @@ -253,8 +253,8 @@ public: class Iterator { friend class SafeList; - SafeListNode *cursor; - SafeList *list; + SafeListNode *cursor = nullptr; + SafeList *list = nullptr; public: Iterator(SafeListNode *p_cursor, SafeList *p_list) : diff --git a/core/templates/self_list.h b/core/templates/self_list.h index 7f2236fa3a..719b5f2e63 100644 --- a/core/templates/self_list.h +++ b/core/templates/self_list.h @@ -108,7 +108,7 @@ public: private: List *_root = nullptr; - T *_self; + T *_self = nullptr; SelfList<T> *_next = nullptr; SelfList<T> *_prev = nullptr; diff --git a/core/templates/set.h b/core/templates/set.h index cdc6e8447d..a8a0a77712 100644 --- a/core/templates/set.h +++ b/core/templates/set.h @@ -328,7 +328,7 @@ private: void _insert_rb_fix(Element *p_new_node) { Element *node = p_new_node; Element *nparent = node->parent; - Element *ngrand_parent; + Element *ngrand_parent = nullptr; while (nparent->color == RED) { ngrand_parent = nparent->parent; @@ -482,7 +482,7 @@ private: Element *rp = ((p_node->left == _data._nil) || (p_node->right == _data._nil)) ? p_node : p_node->_next; Element *node = (rp->left == _data._nil) ? rp->right : rp->left; - Element *sibling; + Element *sibling = nullptr; if (rp == rp->parent->left) { rp->parent->left = node; sibling = rp->parent->right; diff --git a/core/templates/thread_work_pool.h b/core/templates/thread_work_pool.h index 957af44f48..d364ac4fd8 100644 --- a/core/templates/thread_work_pool.h +++ b/core/templates/thread_work_pool.h @@ -68,7 +68,7 @@ class ThreadWorkPool { Semaphore start; Semaphore completed; std::atomic<bool> exit; - BaseWork *work; + BaseWork *work = nullptr; }; ThreadData *threads = nullptr; |