[asterisk-addons-commits] mnicholson: branch mnicholson/chan-mobile-refactor r748 - /team/mnicholson/ch...

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Mon Jan 26 15:26:34 CST 2009


Author: mnicholson
Date: Mon Jan 26 15:26:33 2009
New Revision: 748

URL: http://svn.digium.com/svn-view/asterisk-addons?view=rev&rev=748
Log:
tweak calls to rfcomm_read()

Modified:
    team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c

Modified: team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c
URL: http://svn.digium.com/svn-view/asterisk-addons/team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c?view=diff&rev=748&r1=747&r2=748
==============================================================================
--- team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c (original)
+++ team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c Mon Jan 26 15:26:33 2009
@@ -1380,21 +1380,14 @@
 			t = 1000;
 
 		if (waitfd = rfcomm_wait(pvt->rfcomm_socket, &t)) {
-			s = rfcomm_read(pvt->rfcomm_socket, buf, sizeof(buf));
-
-			if (s < 1) {
+			if ((s = rfcomm_read(pvt->rfcomm_socket, buf, sizeof(buf) - 1)) < 1) {
 				if (option_verbose > 2)
 					ast_verbose(VERBOSE_PREFIX_3  "Bluetooth Device %s has disconnected, reason (%d).\n", pvt->id, errno); 
 				monitor = 0;
 				continue;
 			}
-
-			ast_debug(1, "rfcomm_read() (%s) [%.*s]\n", pvt->id, s, buf);
-
-			if (s < sizeof(buf))
-				buf[s] = '\0';
-			else
-				buf[sizeof(buf) - 1] = '\0';
+			buf[s] = '\0';
+			ast_debug(1, "rfcomm_read() (%s) [%s]\n", pvt->id, buf);
 
 			switch (pvt->state) {
 			case MBL_STATE_INIT:
@@ -1757,21 +1750,14 @@
 			t = 1000;
 		
 		if (waitfd = rfcomm_wait(pvt->rfcomm_socket, &t)) {
-			s = rfcomm_read(pvt->rfcomm_socket, buf, sizeof(buf));
-
-			if (s < 1) {
+			if ((s = rfcomm_read(pvt->rfcomm_socket, buf, sizeof(buf) - 1)) < 1) {
 				if (option_verbose > 2)
 					ast_verbose(VERBOSE_PREFIX_3  "Bluetooth Device %s has disconnected, reason (%d).\n", pvt->id, errno); 
 				monitor = 0;
 				continue;
 			}
-
-			ast_debug(1, "rfcomm_read() (%s) [%.*s]\n", pvt->id, s, buf);
-
-			if (s < sizeof(buf))
-				buf[s] = '\0';
-			else
-				buf[sizeof(buf) - 1] = '\0';
+			buf[s] = '\0';
+			ast_debug(1, "rfcomm_read() (%s) [%s]\n", pvt->id, buf);
 
 			switch (pvt->state) {
 			case MBL_STATE_RING2:




More information about the asterisk-addons-commits mailing list