[svn-commits] tzafrir: branch 1.2 r3222 - /branches/1.2/ztmonitor.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Nov 10 05:33:39 CST 2007


Author: tzafrir
Date: Sat Nov 10 05:33:37 2007
New Revision: 3222

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3222
Log:
Get rid of a pointless static buffer and strcpy.

Modified:
    branches/1.2/ztmonitor.c

Modified: branches/1.2/ztmonitor.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/ztmonitor.c?view=diff&rev=3222&r1=3221&r2=3222
==============================================================================
--- branches/1.2/ztmonitor.c (original)
+++ branches/1.2/ztmonitor.c Sat Nov 10 05:33:37 2007
@@ -259,7 +259,6 @@
 	int pfd[4] = {-1, -1, -1, -1};
 	short buf[8192];
 	short buf2[16384];
-	char  output_file[255];
 	int res, res2;
 	int visual = 0;
 	int multichannel = 0;
@@ -309,6 +308,8 @@
 		} else if ((!strcmp(argv[i], "-f") || !strcmp(argv[i], "-r") || !strcmp(argv[i], "-t")
 				|| !strcmp(argv[i], "-F") || !strcmp(argv[i], "-R") || !strcmp(argv[i], "-T"))
 				&& (i+1) < argc) {
+			char *output_file;
+
 			/* Set which file descriptor to use */
 			if (!strcmp(argv[i], "-f")) {
 				savefile = 1;
@@ -339,17 +340,15 @@
 				x = 0;
 
 			++i; /* we care about the file name */
-			if (strlen(argv[i]) < 255 ) {
-				strcpy(output_file, argv[i]);
-				fprintf(stderr, "Output to %s\n", output_file);
-				if ((ofh[x] = fopen(output_file, "w"))<0) {
-					fprintf(stderr, "Could not open %s for writing: %s\n", output_file, strerror(errno));
-					exit(1);
-				}
-				fprintf(stderr, "Run e.g., 'sox -r 8000 -s -w -c 1 %s file.wav' to convert.\n", output_file);
-			} else {
-				fprintf(stderr, "File Name %s too long\n",argv[i+1]);
-			}
+			output_file = argv[i];
+			fprintf(stderr, "Output to %s\n", output_file);
+			if ((ofh[x] = fopen(output_file, "w"))<0) {
+				fprintf(stderr, "Could not open %s for writing: %s\n", 
+						output_file, strerror(errno));
+				exit(1);
+			}
+			fprintf(stderr, "Run e.g., 'sox -r 8000 -s -w -c 1 %s %s.wav' to convert.\n", 
+					output_file, output_file);
 		} else if (!strcmp(argv[i], "-m")) {
 			multichannel = 1;
 		} else if (!strcmp(argv[i], "-o")) {




More information about the svn-commits mailing list