[Freeswitch-svn] [commit] r6843 - freeswitch/trunk/src

Freeswitch SVN mikej at freeswitch.org
Mon Dec 17 16:08:24 EST 2007


Author: mikej
Date: Mon Dec 17 16:08:24 2007
New Revision: 6843

Modified:
   freeswitch/trunk/src/switch_apr.c
   freeswitch/trunk/src/switch_ivr_async.c
   freeswitch/trunk/src/switch_utils.c

Log:
cleanups and more checking.

Modified: freeswitch/trunk/src/switch_apr.c
==============================================================================
--- freeswitch/trunk/src/switch_apr.c	(original)
+++ freeswitch/trunk/src/switch_apr.c	Mon Dec 17 16:08:24 2007
@@ -476,7 +476,11 @@
 	switch_status_t status;
 	switch_dir_t *dir = malloc(sizeof(*dir));
 
-	switch_assert(dir);
+	if (!dir) {
+		*new_dir = NULL;
+		return SWITCH_STATUS_FALSE;
+	}
+
 	memset(dir, 0, sizeof(*dir));
 	if ((status = apr_dir_open(&(dir->dir_handle), dirname, pool)) == APR_SUCCESS) {
 		*new_dir = dir;
@@ -813,14 +817,19 @@
 	int len;
 	size_t buflen;
 	va_list ap2;
+	char *tmp = NULL;
 
 #ifdef _MSC_VER
+#if _MSC_VER >= 1500
+	/* hack for incorrect assumption in msvc header files for code analysis */
+	__analysis_assume(tmp);
+#endif
 	ap2 = ap;
 #else
 	va_copy(ap2, ap);
 #endif
 
-	len = vsnprintf(NULL, 0, fmt, ap2);
+	len = vsnprintf(tmp, 0, fmt, ap2);
 
 	if (len > 0 && (buf = malloc((buflen = (size_t) (len + 1)))) != NULL) {
 		len = vsnprintf(buf, buflen, fmt, ap);

Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c	(original)
+++ freeswitch/trunk/src/switch_ivr_async.c	Mon Dec 17 16:08:24 2007
@@ -120,25 +120,25 @@
 		break;
 	case SWITCH_ABC_TYPE_READ_REPLACE:
 		{
-			switch_frame_t *frame = switch_core_media_bug_get_read_replace_frame(bug);
+			switch_frame_t *rframe = switch_core_media_bug_get_read_replace_frame(bug);
 			if (dh && !dh->mux) {
-				memset(frame->data, 255, frame->datalen);
+				memset(rframe->data, 255, rframe->datalen);
 			}
-			switch_core_media_bug_set_read_replace_frame(bug, frame);
+			switch_core_media_bug_set_read_replace_frame(bug, rframe);
 		}
 		break;
 	case SWITCH_ABC_TYPE_WRITE_REPLACE:
 		if (dh) {
-			switch_frame_t *frame = NULL;
+			switch_frame_t *rframe = NULL;
 			switch_size_t len;
 			switch_status_t st;
 
-			frame = switch_core_media_bug_get_write_replace_frame(bug);
-			len = frame->samples;
+			rframe = switch_core_media_bug_get_write_replace_frame(bug);
+			len = rframe->samples;
 
 			if (dh->mux) {
 				int16_t buf[1024];
-				int16_t *fp = frame->data;
+				int16_t *fp = rframe->data;
 				uint32_t x;
 
 				st = switch_core_file_read(&dh->fh, buf, &len);
@@ -149,16 +149,16 @@
 					fp[x] = (int16_t) mixed;
 				}
 			} else {
-				st = switch_core_file_read(&dh->fh, frame->data, &len);
-				frame->samples = (uint32_t) len;
-				frame->datalen = frame->samples * 2;
+				st = switch_core_file_read(&dh->fh, rframe->data, &len);
+				rframe->samples = (uint32_t) len;
+				rframe->datalen = rframe->samples * 2;
 			}
 
 			if (st != SWITCH_STATUS_SUCCESS || len == 0) {
 				return SWITCH_FALSE;
 			}
 
-			switch_core_media_bug_set_write_replace_frame(bug, frame);
+			switch_core_media_bug_set_write_replace_frame(bug, rframe);
 		}
 		break;
 	case SWITCH_ABC_TYPE_WRITE:
@@ -358,18 +358,18 @@
 	case SWITCH_ABC_TYPE_READ_REPLACE:
 		{
 			if (switch_test_flag(ep, ED_MUX_READ)) {
-				switch_frame_t *frame = switch_core_media_bug_get_read_replace_frame(bug);
+				switch_frame_t *rframe = switch_core_media_bug_get_read_replace_frame(bug);
 			
-				if (switch_buffer_inuse(ep->r_buffer) >= frame->datalen) {
+				if (switch_buffer_inuse(ep->r_buffer) >= rframe->datalen) {
 					uint32_t bytes;
 					switch_buffer_lock(ep->r_buffer);
-					bytes = (uint32_t) switch_buffer_read(ep->r_buffer, data, frame->datalen);
+					bytes = (uint32_t) switch_buffer_read(ep->r_buffer, data, rframe->datalen);
 			
-					frame->datalen = switch_merge_sln(frame->data, frame->samples, (int16_t *)data, bytes / 2) * 2;
-					frame->samples = frame->datalen / 2;
+					rframe->datalen = switch_merge_sln(rframe->data, rframe->samples, (int16_t *)data, bytes / 2) * 2;
+					rframe->samples = rframe->datalen / 2;
 				
 					switch_buffer_unlock(ep->r_buffer);
-					switch_core_media_bug_set_read_replace_frame(bug, frame);
+					switch_core_media_bug_set_read_replace_frame(bug, rframe);
 				}
 			}
 		}
@@ -378,18 +378,18 @@
 	case SWITCH_ABC_TYPE_WRITE_REPLACE:
 		{
 			if (switch_test_flag(ep, ED_MUX_WRITE)) {
-				switch_frame_t *frame = switch_core_media_bug_get_write_replace_frame(bug);
+				switch_frame_t *rframe = switch_core_media_bug_get_write_replace_frame(bug);
 			
-				if (switch_buffer_inuse(ep->w_buffer) >= frame->datalen) {
+				if (switch_buffer_inuse(ep->w_buffer) >= rframe->datalen) {
 					uint32_t bytes;
 					switch_buffer_lock(ep->w_buffer);
-					bytes = (uint32_t) switch_buffer_read(ep->w_buffer, data, frame->datalen);
+					bytes = (uint32_t) switch_buffer_read(ep->w_buffer, data, rframe->datalen);
 			
-					frame->datalen = switch_merge_sln(frame->data, frame->samples, (int16_t *)data, bytes / 2) * 2;
-					frame->samples = frame->datalen / 2;
+					rframe->datalen = switch_merge_sln(rframe->data, rframe->samples, (int16_t *)data, bytes / 2) * 2;
+					rframe->samples = rframe->datalen / 2;
 				
 					switch_buffer_unlock(ep->w_buffer);
-					switch_core_media_bug_set_write_replace_frame(bug, frame);
+					switch_core_media_bug_set_write_replace_frame(bug, rframe);
 				}
 			}
 		}

Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c	(original)
+++ freeswitch/trunk/src/switch_utils.c	Mon Dec 17 16:08:24 2007
@@ -339,7 +339,9 @@
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to execute command: %s\n", buf);
     }
 
-    unlink(filename);
+	if (unlink(filename) != 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "failed to delete file [%s]\n", filename);
+	}
 
 
     if (file) {



More information about the Freeswitch-svn mailing list