[libpri-commits] rmudgett: branch 1.4 r2027 - in /branches/1.4: pri_internal.h q931.c

SVN commits to the libpri project libpri-commits at lists.digium.com
Fri Oct 15 11:39:16 CDT 2010


Author: rmudgett
Date: Fri Oct 15 11:39:10 2010
New Revision: 2027

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=2027
Log:
Create two versions of call ptr verify.  One gripes and one does not.

Modified:
    branches/1.4/pri_internal.h
    branches/1.4/q931.c

Modified: branches/1.4/pri_internal.h
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri_internal.h?view=diff&rev=2027&r1=2026&r2=2027
==============================================================================
--- branches/1.4/pri_internal.h (original)
+++ branches/1.4/pri_internal.h Fri Oct 15 11:39:10 2010
@@ -883,7 +883,7 @@
 };
 
 /*!
- * \brief Check if the given call ptr is valid.
+ * \brief Check if the given call ptr is valid and gripe if not.
  *
  * \param ctrl D channel controller.
  * \param call Q.931 call leg.
@@ -892,9 +892,10 @@
  * \retval FALSE if call ptr is invalid.
  */
 #define pri_is_call_valid(ctrl, call)	\
-	q931_is_call_valid(ctrl, call, __PRETTY_FUNCTION__, __LINE__)
-
-int q931_is_call_valid(struct pri *ctrl, struct q931_call *call, const char *func_name, unsigned long func_line);
+	q931_is_call_valid_gripe(ctrl, call, __PRETTY_FUNCTION__, __LINE__)
+
+int q931_is_call_valid(struct pri *ctrl, struct q931_call *call);
+int q931_is_call_valid_gripe(struct pri *ctrl, struct q931_call *call, const char *func_name, unsigned long func_line);
 
 extern int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data);
 

Modified: branches/1.4/q931.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/q931.c?view=diff&rev=2027&r1=2026&r2=2027
==============================================================================
--- branches/1.4/q931.c (original)
+++ branches/1.4/q931.c Fri Oct 15 11:39:10 2010
@@ -327,16 +327,13 @@
  *
  * \param ctrl D channel controller.
  * \param call Q.931 call leg.
- * \param func_name Calling function name for debug tracing. (__PRETTY_FUNCTION__)
- * \param func_line Calling function line number for debug tracing. (__LINE__)
  *
  * \retval TRUE if call ptr is valid.
  * \retval FALSE if call ptr is invalid.
  */
-int q931_is_call_valid(struct pri *ctrl, struct q931_call *call, const char *func_name, unsigned long func_line)
+int q931_is_call_valid(struct pri *ctrl, struct q931_call *call)
 {
 	struct q931_call *cur;
-	struct pri *gripe;
 	struct pri *link;
 	int idx;
 
@@ -347,18 +344,14 @@
 	if (!ctrl) {
 		/* Must use suspect ctrl from call ptr. */
 		if (!call->pri) {
-			pri_message(NULL,
-				"!! %s() line:%lu Called with invalid call ptr (%p) (No ctrl)\n",
-				func_name, func_line, call);
+			/* Definitely a bad call pointer. */
 			return 0;
 		}
 		/* Find the master - He has the call pool */
 		ctrl = PRI_MASTER(call->pri);
-		gripe = NULL;
 	} else {
 		/* Find the master - He has the call pool */
 		ctrl = PRI_MASTER(ctrl);
-		gripe = ctrl;
 	}
 
 	/* Check real call records. */
@@ -387,9 +380,34 @@
 	}
 
 	/* Well it looks like this is a stale call ptr. */
-	pri_message(gripe, "!! %s() line:%lu Called with invalid call ptr (%p)\n",
-		func_name, func_line, call);
 	return 0;
+}
+
+/*!
+ * \brief Check if the given call ptr is valid and gripe if not.
+ *
+ * \param ctrl D channel controller.
+ * \param call Q.931 call leg.
+ * \param func_name Calling function name for debug tracing. (__PRETTY_FUNCTION__)
+ * \param func_line Calling function line number for debug tracing. (__LINE__)
+ *
+ * \retval TRUE if call ptr is valid.
+ * \retval FALSE if call ptr is invalid.
+ */
+int q931_is_call_valid_gripe(struct pri *ctrl, struct q931_call *call, const char *func_name, unsigned long func_line)
+{
+	int res;
+
+	if (!call) {
+		/* Let's not gripe about this invalid call pointer. */
+		return 0;
+	}
+	res = q931_is_call_valid(ctrl, call);
+	if (!res) {
+		pri_message(ctrl, "!! %s() line:%lu Called with invalid call ptr (%p)\n",
+			func_name, func_line, call);
+	}
+	return res;
 }
 
 /*!




More information about the libpri-commits mailing list