[Asterisk-code-review] core: Add AO2_ALLOC_OPT_NO_REF_DEBUG option. (...asterisk[master])

George Joseph asteriskteam at digium.com
Wed Sep 25 06:04:22 CDT 2019


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/12912 )

Change subject: core: Add AO2_ALLOC_OPT_NO_REF_DEBUG option.
......................................................................

core: Add AO2_ALLOC_OPT_NO_REF_DEBUG option.

Previous to this patch passing a NULL tag to ao2_alloc or ao2_ref based
functions would result in the reference not being logged under
REF_DEBUG.  This could sometimes cause inaccurate logging if NULL was
accidentally passed to a reference action.  Now reference logging is
only disabled by option passed to the allocation method.

Change-Id: I3c17d867d901d53f9fcd512bef4d52e342637b54
---
M include/asterisk/astobj2.h
M main/astobj2.c
M main/astobj2_container.c
M main/astobj2_hash.c
M main/astobj2_rbtree.c
5 files changed, 71 insertions(+), 70 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h
index e540e46..a135db8 100644
--- a/include/asterisk/astobj2.h
+++ b/include/asterisk/astobj2.h
@@ -198,7 +198,7 @@
 were called to appear in refs log, you can do this sort of thing:
 
 #define my_t_alloc(data,tag)  my_alloc_debug((data), tag, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define my_alloc(data)        my_t_alloc((data), "")
+#define my_alloc(data)        my_t_alloc((data), NULL)
 
 static struct mydata *my_alloc_debug(void *data,
 	const char *tag, const char *file, int line, const char *func)
@@ -376,6 +376,8 @@
 	 * should never be passed directly to ao2_alloc.
 	 */
 	AO2_ALLOC_OPT_LOCK_OBJ = AO2_ALLOC_OPT_LOCK_MASK,
+	/*! The ao2 object will not record any REF_DEBUG entries */
+	AO2_ALLOC_OPT_NO_REF_DEBUG = (1 << 2),
 };
 
 /*!
@@ -396,20 +398,18 @@
  * - the returned pointer cannot be free()'d or realloc()'ed;
  *   rather, we just call ao2_ref(o, -1);
  *
- * \note refdebug logging is skipped if debug_msg is NULL
- *
  * @{
  */
 
 #define ao2_t_alloc_options(data_size, destructor_fn, options, debug_msg) \
 	__ao2_alloc((data_size), (destructor_fn), (options), (debug_msg),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_alloc_options(data_size, destructor_fn, options) \
-	__ao2_alloc((data_size), (destructor_fn), (options), "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_alloc((data_size), (destructor_fn), (options), NULL,  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 #define ao2_t_alloc(data_size, destructor_fn, debug_msg) \
 	__ao2_alloc((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_MUTEX, (debug_msg),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_alloc(data_size, destructor_fn) \
-	__ao2_alloc((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_MUTEX, "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_alloc((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_MUTEX, NULL,  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 void *__ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, unsigned int options,
 	const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result;
@@ -457,12 +457,11 @@
  * can go away is when we release our reference, and it is
  * the last one in existence.
  *
- * \note refdebug logging is skipped if tag is NULL
  * @{
  */
 
 #define ao2_t_ref(o,delta,tag) __ao2_ref((o), (delta), (tag),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define ao2_ref(o,delta)       __ao2_ref((o), (delta), "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_ref(o,delta)       __ao2_ref((o), (delta), NULL,  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 /*!
  * \brief Retrieve the ao2 options used to create the object.
@@ -490,7 +489,7 @@
 		__obj_ ## __LINE__;				\
 	})
 #define ao2_bump(obj) \
-	ao2_t_bump((obj), "")
+	ao2_t_bump((obj), NULL)
 
 int __ao2_ref(void *o, int delta, const char *tag, const char *file, int line, const char *func);
 
@@ -516,7 +515,7 @@
 		} \
 	}
 #define ao2_replace(dst, src) \
-	ao2_t_replace((dst), (src), "")
+	ao2_t_replace((dst), (src), NULL)
 
 /*! @} */
 
@@ -553,7 +552,7 @@
 	const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result;
 
 #define ao2_weakproxy_alloc(data_size, destructor_fn) \
-	__ao2_weakproxy_alloc(data_size, destructor_fn, "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_weakproxy_alloc(data_size, destructor_fn, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 #define ao2_t_weakproxy_alloc(data_size, destructor_fn, tag) \
 	__ao2_weakproxy_alloc(data_size, destructor_fn, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__)
@@ -582,7 +581,7 @@
 	const char *tag, const char *file, int line, const char *func);
 
 #define ao2_weakproxy_set_object(weakproxy, obj, flags) \
-	__ao2_weakproxy_set_object(weakproxy, obj, flags, "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_weakproxy_set_object(weakproxy, obj, flags, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 #define ao2_t_weakproxy_set_object(weakproxy, obj, flags, tag) \
 	__ao2_weakproxy_set_object(weakproxy, obj, flags, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__)
@@ -608,7 +607,7 @@
 		tag, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 #define ao2_weakproxy_ref_object(weakproxy, delta, flags) \
-	ao2_t_weakproxy_ref_object(weakproxy, delta, flags, "")
+	ao2_t_weakproxy_ref_object(weakproxy, delta, flags, NULL)
 
 /*!
  * \since 14.0.0
@@ -624,7 +623,7 @@
 	const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result;
 
 #define ao2_weakproxy_get_object(weakproxy, flags) \
-	__ao2_weakproxy_get_object(weakproxy, flags, "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_weakproxy_get_object(weakproxy, flags, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 #define ao2_t_weakproxy_get_object(weakproxy, flags, tag) \
 	__ao2_weakproxy_get_object(weakproxy, flags, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__)
@@ -691,7 +690,7 @@
 	const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result;
 
 #define ao2_get_weakproxy(obj) \
-	__ao2_get_weakproxy(obj, "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_get_weakproxy(obj, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 #define ao2_t_get_weakproxy(obj, tag) \
 	__ao2_get_weakproxy(obj, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__)
@@ -864,7 +863,7 @@
 #define ao2_t_global_obj_release(holder, tag)	\
 	__ao2_global_obj_replace_unref(&holder, NULL, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 #define ao2_global_obj_release(holder)	\
-	__ao2_global_obj_replace_unref(&holder, NULL, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+	__ao2_global_obj_replace_unref(&holder, NULL, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 
 /*!
  * \brief Replace an ao2 object in the global holder.
@@ -884,7 +883,7 @@
 #define ao2_t_global_obj_replace(holder, obj, tag)	\
 	__ao2_global_obj_replace(&holder, (obj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 #define ao2_global_obj_replace(holder, obj)	\
-	__ao2_global_obj_replace(&holder, (obj), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+	__ao2_global_obj_replace(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 
 void *__ao2_global_obj_replace(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name) attribute_warn_unused_result;
 
@@ -907,7 +906,7 @@
 #define ao2_t_global_obj_replace_unref(holder, obj, tag)	\
 	__ao2_global_obj_replace_unref(&holder, (obj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 #define ao2_global_obj_replace_unref(holder, obj)	\
-	__ao2_global_obj_replace_unref(&holder, (obj), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+	__ao2_global_obj_replace_unref(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 
 int __ao2_global_obj_replace_unref(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name);
 
@@ -924,7 +923,7 @@
 #define ao2_t_global_obj_ref(holder, tag)	\
 	__ao2_global_obj_ref(&holder, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 #define ao2_global_obj_ref(holder)	\
-	__ao2_global_obj_ref(&holder, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+	__ao2_global_obj_ref(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 
 void *__ao2_global_obj_ref(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name) attribute_warn_unused_result;
 
@@ -1309,7 +1308,7 @@
 #define ao2_t_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn, tag) \
 	__ao2_container_alloc_hash((ao2_options), (container_options), (n_buckets), (hash_fn), (sort_fn), (cmp_fn), (tag),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn) \
-	__ao2_container_alloc_hash((ao2_options), (container_options), (n_buckets), (hash_fn), (sort_fn), (cmp_fn), "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_container_alloc_hash((ao2_options), (container_options), (n_buckets), (hash_fn), (sort_fn), (cmp_fn), NULL,  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 struct ao2_container *__ao2_container_alloc_hash(unsigned int ao2_options,
 	unsigned int container_options, unsigned int n_buckets, ao2_hash_fn *hash_fn,
@@ -1334,7 +1333,7 @@
 #define ao2_t_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn, tag) \
 	__ao2_container_alloc_list((ao2_options), (container_options), (sort_fn), (cmp_fn), (tag),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn) \
-	__ao2_container_alloc_list((ao2_options), (container_options), (sort_fn), (cmp_fn), "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_container_alloc_list((ao2_options), (container_options), (sort_fn), (cmp_fn), NULL,  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 struct ao2_container *__ao2_container_alloc_list(unsigned int ao2_options,
 	unsigned int container_options, ao2_sort_fn *sort_fn, ao2_callback_fn *cmp_fn,
@@ -1357,7 +1356,7 @@
 #define ao2_t_container_alloc_rbtree(ao2_options, container_options, sort_fn, cmp_fn, tag) \
 	__ao2_container_alloc_rbtree((ao2_options), (container_options), (sort_fn), (cmp_fn), (tag),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_container_alloc_rbtree(ao2_options, container_options, sort_fn, cmp_fn) \
-	__ao2_container_alloc_rbtree((ao2_options), (container_options), (sort_fn), (cmp_fn), "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_container_alloc_rbtree((ao2_options), (container_options), (sort_fn), (cmp_fn), NULL,  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 struct ao2_container *__ao2_container_alloc_rbtree(unsigned int ao2_options, unsigned int container_options,
 	ao2_sort_fn *sort_fn, ao2_callback_fn *cmp_fn,
@@ -1429,7 +1428,7 @@
 #define ao2_t_container_clone(orig, flags, tag) \
 	__ao2_container_clone(orig, flags, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_container_clone(orig, flags) \
-	__ao2_container_clone(orig, flags, "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_container_clone(orig, flags, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 /*!
  * \brief Print output.
@@ -1548,7 +1547,7 @@
 #define ao2_t_link(container, obj, tag) \
 	__ao2_link((container), (obj), 0, (tag),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_link(container, obj) \
-	__ao2_link((container), (obj), 0, "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_link((container), (obj), 0, NULL,  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 /*!
  * \brief Add an object to a container.
@@ -1571,7 +1570,7 @@
 #define ao2_t_link_flags(container, obj, flags, tag) \
 	__ao2_link((container), (obj), (flags), (tag),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_link_flags(container, obj, flags) \
-	__ao2_link((container), (obj), (flags), "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_link((container), (obj), (flags), NULL,  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 int __ao2_link(struct ao2_container *c, void *obj_new, int flags,
 	const char *tag, const char *file, int line, const char *func);
@@ -1597,7 +1596,7 @@
 #define ao2_t_unlink(container, obj, tag) \
 	__ao2_unlink((container), (obj), 0, (tag),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_unlink(container, obj) \
-	__ao2_unlink((container), (obj), 0, "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_unlink((container), (obj), 0, NULL,  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 /*!
  * \brief Remove an object from a container
@@ -1621,7 +1620,7 @@
 #define ao2_t_unlink_flags(container, obj, flags, tag) \
 	__ao2_unlink((container), (obj), (flags), (tag),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_unlink_flags(container, obj, flags) \
-	__ao2_unlink((container), (obj), (flags), "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_unlink((container), (obj), (flags), NULL,  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 void *__ao2_unlink(struct ao2_container *c, void *obj, int flags,
 	const char *tag, const char *file, int line, const char *func);
@@ -1715,7 +1714,7 @@
 #define ao2_t_callback(c, flags, cb_fn, arg, tag) \
 	__ao2_callback((c), (flags), (cb_fn), (arg), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_callback(c, flags, cb_fn, arg) \
-	__ao2_callback((c), (flags), (cb_fn), (arg), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_callback((c), (flags), (cb_fn), (arg), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 void *__ao2_callback(struct ao2_container *c, enum search_flags flags,
 	ao2_callback_fn *cb_fn, void *arg, const char *tag, const char *file, int line,
@@ -1742,7 +1741,7 @@
 #define ao2_t_callback_data(container, flags, cb_fn, arg, data, tag) \
 	__ao2_callback_data((container), (flags), (cb_fn), (arg), (data), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_callback_data(container, flags, cb_fn, arg, data) \
-	__ao2_callback_data((container), (flags), (cb_fn), (arg), (data), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_callback_data((container), (flags), (cb_fn), (arg), (data), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 void *__ao2_callback_data(struct ao2_container *c, enum search_flags flags,
 	ao2_callback_data_fn *cb_fn, void *arg, void *data, const char *tag, const char *file,
@@ -1755,7 +1754,7 @@
 #define ao2_t_find(container, arg, flags, tag) \
 	__ao2_find((container), (arg), (flags), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_find(container, arg, flags) \
-	__ao2_find((container), (arg), (flags), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_find((container), (arg), (flags), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 void *__ao2_find(struct ao2_container *c, const void *arg, enum search_flags flags,
 	const char *tag, const char *file, int line, const char *func);
@@ -1932,7 +1931,7 @@
 #define ao2_t_iterator_next(iter, tag) \
 	__ao2_iterator_next((iter), (tag),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_iterator_next(iter) \
-	__ao2_iterator_next((iter), "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+	__ao2_iterator_next((iter), NULL,  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 void *__ao2_iterator_next(struct ao2_iterator *iter,
 	const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result;
@@ -1956,7 +1955,7 @@
  * down a NULL */
 void __ao2_cleanup(void *obj);
 void __ao2_cleanup_debug(void *obj, const char *tag, const char *file, int line, const char *function);
-#define ao2_cleanup(obj) __ao2_cleanup_debug((obj), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_cleanup(obj) __ao2_cleanup_debug((obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define ao2_t_cleanup(obj, tag) __ao2_cleanup_debug((obj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__)
 void ao2_iterator_cleanup(struct ao2_iterator *iter);
 
diff --git a/main/astobj2.c b/main/astobj2.c
index ebc0720..fb5bd0e 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -67,7 +67,7 @@
 	 * \note This field is constant after object creation.  It shares
 	 *       a uint32_t with \ref lockused and \ref magic.
 	 */
-	uint32_t options:2;
+	uint32_t options:3;
 	/*!
 	 * \brief Set to 1 when the lock is used if refdebug is enabled.
 	 *
@@ -90,11 +90,11 @@
 	 *          all bitfields into a single 'uint32_t flags' field and use
 	 *          atomic operations from \file lock.h to perform writes.
 	 */
-	uint32_t magic:29;
+	uint32_t magic:28;
 };
 
-#define	AO2_MAGIC	0x1a70b123
-#define	AO2_WEAK	0x1a70b122
+#define	AO2_MAGIC	0xa70b123
+#define	AO2_WEAK	0xa70b122
 #define IS_AO2_MAGIC_BAD(p) (AO2_MAGIC != (p->priv_data.magic | 1))
 
 /*!
@@ -585,10 +585,10 @@
 			__ast_assert_failed(0, excessive_ref_buf, file, line, func);
 		}
 
-		if (ref_log && tag) {
+		if (ref_log && !(obj->priv_data.options & AO2_ALLOC_OPT_NO_REF_DEBUG)) {
 			fprintf(ref_log, "%p,%s%d,%d,%s,%d,%s,%d,%s\n", user_data,
 				(delta < 0 ? "" : "+"), delta, ast_get_tid(),
-				file, line, func, (int)ret, tag);
+				file, line, func, (int)ret, tag ?: "");
 			fflush(ref_log);
 		}
 		return ret;
@@ -599,7 +599,7 @@
 		ast_log(__LOG_ERROR, file, line, func,
 			"Invalid refcount %d on ao2 object %p\n", (int)current_value, user_data);
 		if (ref_log) {
-			/* Log to ref_log invalid even if (tag == NULL) */
+			/* Log to ref_log even if AO2_ALLOC_OPT_NO_REF_DEBUG */
 			fprintf(ref_log, "%p,%d,%d,%s,%d,%s,**invalid**,%s\n",
 				user_data, delta, ast_get_tid(), file, line, func, tag ?: "");
 			fflush(ref_log);
@@ -655,9 +655,9 @@
 		break;
 	}
 
-	if (ref_log && tag) {
+	if (ref_log && !(obj->priv_data.options & AO2_ALLOC_OPT_NO_REF_DEBUG)) {
 		fprintf(ref_log, "%p,%d,%d,%s,%d,%s,**destructor**lock-state:%s**,%s\n",
-			user_data, delta, ast_get_tid(), file, line, func, lock_state, tag);
+			user_data, delta, ast_get_tid(), file, line, func, lock_state, tag ?: "");
 		fflush(ref_log);
 	}
 
@@ -752,9 +752,9 @@
 	ast_atomic_fetchadd_int(&ao2.total_refs, 1);
 #endif
 
-	if (ref_log && tag) {
+	if (ref_log && !(obj->priv_data.options & AO2_ALLOC_OPT_NO_REF_DEBUG)) {
 		fprintf(ref_log, "%p,+1,%d,%s,%d,%s,**constructor**%zu**%zu**,%s\n",
-			EXTERNAL_OBJ(obj), ast_get_tid(), file, line, func, overhead, data_size, tag);
+			EXTERNAL_OBJ(obj), ast_get_tid(), file, line, func, overhead, data_size, tag ?: "");
 		fflush(ref_log);
 	}
 
diff --git a/main/astobj2_container.c b/main/astobj2_container.c
index 9a837bd..0b580e6 100644
--- a/main/astobj2_container.c
+++ b/main/astobj2_container.c
@@ -70,7 +70,7 @@
 
 	if (flags & AO2_UNLINK_NODE_UNREF_NODE) {
 		/* Remove node from container */
-		ao2_t_ref(node, -1, NULL);
+		ao2_ref(node, -1);
 	}
 
 	return 1;
@@ -146,7 +146,7 @@
 			res = 1;
 			break;
 		case AO2_CONTAINER_INSERT_NODE_REJECTED:
-			ao2_t_ref(node, -1, NULL);
+			ao2_ref(node, -1);
 			break;
 		}
 	}
@@ -386,7 +386,7 @@
 	}
 	if (node) {
 		/* Unref the node from self->v_table->traverse_first/traverse_next() */
-		ao2_t_ref(node, -1, NULL);
+		ao2_ref(node, -1);
 	}
 
 	if (flags & OBJ_NOLOCK) {
@@ -517,7 +517,7 @@
 			ao2_rdlock(iter->c);
 		}
 
-		ao2_t_ref(iter->last_node, -1, NULL);
+		ao2_ref(iter->last_node, -1);
 		iter->last_node = NULL;
 
 		if (iter->flags & AO2_ITERATOR_DONTLOCK) {
@@ -604,7 +604,7 @@
 			__ao2_ref(ret, +1, tag ?: "Next iterator object.", file, line, func);
 
 			/* Bump the container's node ref for the iterator. */
-			ao2_t_ref(node, +1, NULL);
+			ao2_ref(node, +1);
 		}
 	} else {
 		/* The iteration has completed. */
@@ -614,7 +614,7 @@
 
 	/* Replace the iterator's node */
 	if (iter->last_node) {
-		ao2_t_ref(iter->last_node, -1, NULL);
+		ao2_ref(iter->last_node, -1);
 	}
 	iter->last_node = node;
 
@@ -667,7 +667,7 @@
 {
 	struct ao2_container *dest = arg;
 
-	return ao2_t_link_flags(dest, obj, OBJ_NOLOCK, NULL) ? 0 : (CMP_MATCH | CMP_STOP);
+	return ao2_link_flags(dest, obj, OBJ_NOLOCK) ? 0 : (CMP_MATCH | CMP_STOP);
 }
 
 int ao2_container_dup(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags)
@@ -685,8 +685,8 @@
 		ao2_t_ref(obj, -1, "Failed to put this object into the dest container.");
 
 		/* Remove all items from the dest container. */
-		ao2_t_callback(dest, OBJ_NOLOCK | OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL,
-			NULL, NULL);
+		ao2_callback(dest, OBJ_NOLOCK | OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL,
+			NULL);
 		res = -1;
 	}
 	if (!(flags & OBJ_NOLOCK)) {
@@ -717,7 +717,7 @@
 		return 0;
 	}
 
-	ret = ao2_t_link_flags(dest, obj, OBJ_NOLOCK, NULL) ? 0 : (CMP_MATCH | CMP_STOP);
+	ret = ao2_link_flags(dest, obj, OBJ_NOLOCK) ? 0 : (CMP_MATCH | CMP_STOP);
 	ao2_ref(obj, -1);
 
 	return ret;
@@ -738,8 +738,8 @@
 		ao2_t_ref(obj, -1, "Failed to put this object into the dest container.");
 
 		/* Remove all items from the dest container. */
-		ao2_t_callback(dest, OBJ_NOLOCK | OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL,
-			NULL, NULL);
+		ao2_callback(dest, OBJ_NOLOCK | OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL,
+			NULL);
 		res = -1;
 	}
 	if (!(flags & OBJ_NOLOCK)) {
diff --git a/main/astobj2_hash.c b/main/astobj2_hash.c
index 55077c5..c24b8a0 100644
--- a/main/astobj2_hash.c
+++ b/main/astobj2_hash.c
@@ -210,7 +210,8 @@
 	struct hash_bucket_node *node;
 	int i;
 
-	node = ao2_t_alloc_options(sizeof(*node), hash_ao2_node_destructor, AO2_ALLOC_OPT_LOCK_NOLOCK, NULL);
+	node = ao2_alloc_options(sizeof(*node), hash_ao2_node_destructor,
+		AO2_ALLOC_OPT_LOCK_NOLOCK | AO2_ALLOC_OPT_NO_REF_DEBUG);
 	if (!node) {
 		return NULL;
 	}
@@ -274,7 +275,7 @@
 					break;
 				case AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE:
 					SWAP(cur->common.obj, node->common.obj);
-					ao2_t_ref(node, -1, NULL);
+					ao2_ref(node, -1);
 					return AO2_CONTAINER_INSERT_NODE_OBJ_REPLACED;
 				}
 			}
@@ -307,7 +308,7 @@
 					break;
 				case AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE:
 					SWAP(cur->common.obj, node->common.obj);
-					ao2_t_ref(node, -1, NULL);
+					ao2_ref(node, -1);
 					return AO2_CONTAINER_INSERT_NODE_OBJ_REPLACED;
 				}
 			}
@@ -415,7 +416,7 @@
 				}
 
 				/* We have the first traversal node */
-				ao2_t_ref(node, +1, NULL);
+				ao2_ref(node, +1);
 				return node;
 			}
 		}
@@ -457,7 +458,7 @@
 				}
 
 				/* We have the first traversal node */
-				ao2_t_ref(node, +1, NULL);
+				ao2_ref(node, +1);
 				return node;
 			}
 		}
@@ -526,7 +527,7 @@
 				}
 
 				/* We have the next traversal node */
-				ao2_t_ref(node, +1, NULL);
+				ao2_ref(node, +1);
 
 				/*
 				 * Dereferencing the prev node may result in our next node
@@ -534,7 +535,7 @@
 				 * the container uses RW locks and the container was read
 				 * locked.
 				 */
-				ao2_t_ref(prev, -1, NULL);
+				ao2_ref(prev, -1);
 				if (node->common.obj) {
 					return node;
 				}
@@ -570,7 +571,7 @@
 				}
 
 				/* We have the next traversal node */
-				ao2_t_ref(node, +1, NULL);
+				ao2_ref(node, +1);
 
 				/*
 				 * Dereferencing the prev node may result in our next node
@@ -578,7 +579,7 @@
 				 * the container uses RW locks and the container was read
 				 * locked.
 				 */
-				ao2_t_ref(prev, -1, NULL);
+				ao2_ref(prev, -1);
 				if (node->common.obj) {
 					return node;
 				}
@@ -590,7 +591,7 @@
 	}
 
 	/* No more nodes in the container left to traverse. */
-	ao2_t_ref(prev, -1, NULL);
+	ao2_ref(prev, -1);
 	return NULL;
 }
 
diff --git a/main/astobj2_rbtree.c b/main/astobj2_rbtree.c
index 73d6896..d7c76e6 100644
--- a/main/astobj2_rbtree.c
+++ b/main/astobj2_rbtree.c
@@ -905,7 +905,8 @@
 {
 	struct rbtree_node *node;
 
-	node = ao2_t_alloc_options(sizeof(*node), rb_ao2_node_destructor, AO2_ALLOC_OPT_LOCK_NOLOCK, NULL);
+	node = ao2_alloc_options(sizeof(*node), rb_ao2_node_destructor,
+		AO2_ALLOC_OPT_LOCK_NOLOCK | AO2_ALLOC_OPT_NO_REF_DEBUG);
 	if (!node) {
 		return NULL;
 	}
@@ -1243,7 +1244,7 @@
 		break;
 	case AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE:
 		SWAP(cur->common.obj, node->common.obj);
-		ao2_t_ref(node, -1, NULL);
+		ao2_ref(node, -1);
 		return AO2_CONTAINER_INSERT_NODE_OBJ_REPLACED;
 	}
 
@@ -1313,7 +1314,7 @@
 		}
 
 		/* We have the next traversal node */
-		ao2_t_ref(node, +1, NULL);
+		ao2_ref(node, +1);
 
 		/*
 		 * Dereferencing the prev node may result in our next node
@@ -1321,7 +1322,7 @@
 		 * the container uses RW locks and the container was read
 		 * locked.
 		 */
-		ao2_t_ref(prev, -1, NULL);
+		ao2_ref(prev, -1);
 		if (node->common.obj) {
 			return node;
 		}
@@ -1329,7 +1330,7 @@
 	}
 
 	/* No more nodes in the container left to traverse. */
-	ao2_t_ref(prev, -1, NULL);
+	ao2_ref(prev, -1);
 	return NULL;
 }
 
@@ -1612,7 +1613,7 @@
 	}
 
 	/* We have the first traversal node */
-	ao2_t_ref(node, +1, NULL);
+	ao2_ref(node, +1);
 	return node;
 }
 

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/12912
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I3c17d867d901d53f9fcd512bef4d52e342637b54
Gerrit-Change-Number: 12912
Gerrit-PatchSet: 3
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190925/a3c16903/attachment-0001.html>


More information about the asterisk-code-review mailing list