[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step1 r299189 - in /team/dvossel/f...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 20 20:32:18 UTC 2010


Author: dvossel
Date: Mon Dec 20 14:32:14 2010
New Revision: 299189

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=299189
Log:
Format API takes care of ending the va_lists used by the interface set functions

Modified:
    team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h
    team/dvossel/fixtheworld_phase1_step1/main/format.c
    team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c

Modified: team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h?view=diff&rev=299189&r1=299188&r2=299189
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h (original)
+++ team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h Mon Dec 20 14:32:14 2010
@@ -152,7 +152,7 @@
     int (* const format_attr_get_joint)(struct ast_format_attr *fattr1, struct ast_format_attr *fattr2, struct ast_format_attr *result);
 
     /*! \brief Set format capabilities from a list of key value pairs ending with AST_FORMAT_ATTR_END.
-	 * \note This function is expected to call va_end(ap) after processing the va_list. */
+	 * \note This function does not need to call va_end of the va_list. */
     void (* const format_attr_set)(struct ast_format_attr *format_attr, va_list ap);
 };
 

Modified: team/dvossel/fixtheworld_phase1_step1/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step1/main/format.c?view=diff&rev=299189&r1=299188&r2=299189
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/main/format.c (original)
+++ team/dvossel/fixtheworld_phase1_step1/main/format.c Mon Dec 20 14:32:14 2010
@@ -87,13 +87,11 @@
 	};
 
 	if (!interfaces) {
-		va_end(ap);
 		return -1;
 	}
 
 	ast_rwlock_rdlock(&ilock);
 	if (!(wrapper = ao2_find(interfaces, &tmp_wrapper, (OBJ_POINTER | OBJ_NOLOCK)))) {
-		va_end(ap);
 		ast_log(LOG_WARNING, "Could not find format interface to set\n");
 		ast_rwlock_unlock(&ilock);
 		return -1;
@@ -104,11 +102,9 @@
 	if (!wrapper->interface || !wrapper->interface->format_attr_set) {
 		ast_rwlock_unlock(&wrapper->wraplock);
 		ao2_ref(wrapper, -1);
-		va_end(ap);
-		return -1;
-	}
-
-	/* The interface is responsible for calling va_end() now. */
+		return -1;
+	}
+
 	wrapper->interface->format_attr_set(&format->fattr, ap);
 
 	ast_rwlock_unlock(&wrapper->wraplock);
@@ -128,6 +124,7 @@
 		va_list ap;
 		va_start(ap, set_attributes);
 		format_set_helper(format, ap);
+		va_end(ap);
 	}
 
 	return format;
@@ -149,13 +146,11 @@
 	};
 
 	if (!interfaces) {
-		va_end(ap);
 		return -1;
 	}
 
 	ast_rwlock_rdlock(&ilock);
 	if (!(wrapper = ao2_find(interfaces, &tmp_wrapper, (OBJ_POINTER | OBJ_NOLOCK)))) {
-		va_end(ap);
 		ast_rwlock_unlock(&ilock);
 		return -1;
 	}
@@ -168,11 +163,9 @@
 
 		ast_rwlock_unlock(&wrapper->wraplock);
 		ao2_ref(wrapper, -1);
-		va_end(ap);
-		return -1;
-	}
-
-	/* The interface is responsible for calling va_end() now. */
+		return -1;
+	}
+
 	wrapper->interface->format_attr_set(&tmp.fattr, ap);
 
 	/* use our tmp structure to tell if the attributes are set or not */
@@ -187,9 +180,12 @@
 int ast_format_isset(struct ast_format *format, ... )
 {
 	va_list ap;
+	int res;
+
 	va_start(ap, format);
-
-	return format_isset_helper(format, ap);
+	res = format_isset_helper(format, ap);
+	va_end(ap);
+	return res;
 }
 
 

Modified: team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c?view=diff&rev=299189&r1=299188&r2=299189
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c (original)
+++ team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c Mon Dec 20 14:32:14 2010
@@ -122,7 +122,6 @@
 			ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
 		}
 	}
-	va_end(ap);
 }
 
 /*! uLaw does not actually have any attributes associated with it.




More information about the asterisk-commits mailing list