[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r303902 - /team/dvossel/fixt...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 25 13:35:44 CST 2011


Author: dvossel
Date: Tue Jan 25 13:35:41 2011
New Revision: 303902

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=303902
Log:
Addresses reviewboard comments

Modified:
    team/dvossel/fixtheworld_phase1_step3/main/format.c
    team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
    team/dvossel/fixtheworld_phase1_step3/main/translate.c

Modified: team/dvossel/fixtheworld_phase1_step3/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format.c?view=diff&rev=303902&r1=303901&r2=303902
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format.c Tue Jan 25 13:35:41 2011
@@ -262,15 +262,11 @@
 	}
 
 	ast_rwlock_rdlock(&wrapper->wraplock);
-	if (!wrapper->interface || !wrapper->interface->format_attr_get_joint) {
-		ast_rwlock_unlock(&wrapper->wraplock);
-		ao2_ref(wrapper, -1);
-		return res;
-	}
-
-	res = wrapper->interface->format_attr_get_joint(&format1->fattr, &format2->fattr, &result->fattr);
-
+	if (wrapper->interface && wrapper->interface->format_attr_get_joint) {
+		res = wrapper->interface->format_attr_get_joint(&format1->fattr, &format2->fattr, &result->fattr);
+	}
 	ast_rwlock_unlock(&wrapper->wraplock);
+
 	ao2_ref(wrapper, -1);
 
 	return res;
@@ -492,10 +488,13 @@
 
 int ast_format_attr_init()
 {
-	if (!(interfaces = ao2_container_alloc(256, interface_hash_cb, interface_cmp_cb))) {
-		return -1;
-	}
-	ast_rwlock_init(&ilock);
+	if (ast_rwlock_init(&ilock)) {
+		return -1;
+	}
+	if (!(interfaces = ao2_container_alloc(283, interface_hash_cb, interface_cmp_cb))) {
+		ast_rwlock_destroy(&ilock);
+		return -1;
+	}
 	return 0;
 }
 

Modified: team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format_cap.c?view=diff&rev=303902&r1=303901&r2=303902
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format_cap.c Tue Jan 25 13:35:41 2011
@@ -71,7 +71,7 @@
 		return NULL;
 	}
 	cap->nolock = nolock ? OBJ_NOLOCK : 0;
-	if (!(cap->formats = ao2_container_alloc(256, hash_cb, cmp_cb))) {
+	if (!(cap->formats = ao2_container_alloc(283, hash_cb, cmp_cb))) {
 		ast_free(cap);
 		return NULL;
 	}
@@ -257,21 +257,19 @@
 	return -1;
 }
 
+static int multiple_by_type_cb(void *obj, void *arg, int flag)
+{
+	int *type = arg;
+	struct ast_format *format = obj;
+	return ((AST_FORMAT_GET_TYPE(format->id)) == *type) ? CMP_MATCH : 0;
+}
+
 void ast_format_cap_remove_bytype(struct ast_format_cap *cap, enum ast_format_type type)
 {
-	/* There is no benifit of using an ao2 callback here. Instead
-	 * the container is just interated over */
-	struct ao2_iterator it;
-	struct ast_format *tmp;
-
-	it = ao2_iterator_init(cap->formats, cap->nolock ? AO2_ITERATOR_DONTLOCK : 0);
-	while ((tmp = ao2_iterator_next(&it))) {
-		if (AST_FORMAT_GET_TYPE(tmp->id) == type) {
-			ao2_callback(cap->formats, OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA | cap->nolock, cmp_cb, tmp);
-		}
-		ao2_ref(tmp, -1);
-	}
-	ao2_iterator_destroy(&it);
+	ao2_callback(cap->formats,
+		OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE | cap->nolock,
+		multiple_by_type_cb,
+		&type);
 }
 
 void ast_format_cap_remove_all(struct ast_format_cap *cap)
@@ -326,9 +324,10 @@
 {
 	struct ao2_iterator it;
 	struct ast_format *tmp;
-	struct find_joint_data data;
-	data.joint_found = 0;
-	data.joint_cap = NULL;
+	struct find_joint_data data = {
+		.joint_found = 0,
+		.joint_cap = NULL,
+	};
 
 	it = ao2_iterator_init(cap1->formats, cap1->nolock ? AO2_ITERATOR_DONTLOCK : 0);
 	while ((tmp = ao2_iterator_next(&it))) {
@@ -372,13 +371,13 @@
 	struct ao2_iterator it;
 	struct ast_format_cap *result = ast_format_cap_alloc_nolock();
 	struct ast_format *tmp;
-	struct find_joint_data data;
-
+	struct find_joint_data data = {
+		.joint_found = 0,
+		.joint_cap = result,
+	};
 	if (!result) {
 		return NULL;
 	}
-	data.joint_cap = result;
-	data.joint_found = 0;
 
 	it = ao2_iterator_init(cap1->formats, cap1->nolock ? AO2_ITERATOR_DONTLOCK : 0);
 	while ((tmp = ao2_iterator_next(&it))) {

Modified: team/dvossel/fixtheworld_phase1_step3/main/translate.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/translate.c?view=diff&rev=303902&r1=303901&r2=303902
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/translate.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/translate.c Tue Jan 25 13:35:41 2011
@@ -56,7 +56,7 @@
 	struct ast_translator *step;       /*!< Next step translator */
 	uint32_t table_cost;               /*!< Complete table cost to destination */
 	uint8_t multistep;                 /*!< Multiple conversions required for this translation */
-} __attribute__((packed));
+};
 
 /*!
  * \brief a matrix that, for any pair of supported formats,
@@ -113,7 +113,7 @@
 	return -1; /* not found */
 }
 
-/*
+/*!
  * \internal
  * \brief add a new format to the matrix and index table structures.
  *
@@ -145,7 +145,7 @@
  * \internal
  * \brief converts index value back to format id
  */
-static force_inline enum ast_format_id index2format(int index)
+static enum ast_format_id index2format(int index)
 {
 	enum ast_format_id format_id;
 
@@ -159,7 +159,7 @@
 	return format_id;
 }
 
-/*
+/*!
  * \internal
  * \brief resize both the matrix and index table so they can represent
  * more translators




More information about the asterisk-commits mailing list