[FFmpeg-cvslog] tests/tools/examples: Replace direct exit() calls by return.

Diego Biurrun git at videolan.org
Fri Dec 9 00:18:55 CET 2011


ffmpeg | branch: master | Diego Biurrun <diego at biurrun.de> | Wed Sep 21 18:46:56 2011 +0200| [9a5d6c23c5cc25b887f996d55f96dfbacf760e88] | committer: Diego Biurrun

tests/tools/examples: Replace direct exit() calls by return.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9a5d6c23c5cc25b887f996d55f96dfbacf760e88
---

 libavcodec/fft-test.c        |    5 +----
 libavcodec/motion-test.c     |    4 +---
 libavformat/output-example.c |   10 +++++-----
 libavformat/seek-test.c      |    7 +++----
 tools/cws2fws.c              |   18 +++++++++---------
 5 files changed, 19 insertions(+), 25 deletions(-)

diff --git a/libavcodec/fft-test.c b/libavcodec/fft-test.c
index 59a53dd..f890de6 100644
--- a/libavcodec/fft-test.c
+++ b/libavcodec/fft-test.c
@@ -37,8 +37,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#undef exit
-
 /* reference fft */
 
 #define MUL16(a,b) ((a) * (b))
@@ -228,7 +226,6 @@ static void help(void)
            "-n b   set the transform size to 2^b\n"
            "-f x   set scale factor for output data of (I)MDCT to x\n"
            );
-    exit(1);
 }
 
 enum tf_transform {
@@ -267,7 +264,7 @@ int main(int argc, char **argv)
         switch(c) {
         case 'h':
             help();
-            break;
+            return 1;
         case 's':
             do_speed = 1;
             break;
diff --git a/libavcodec/motion-test.c b/libavcodec/motion-test.c
index f689824..b054fc9 100644
--- a/libavcodec/motion-test.c
+++ b/libavcodec/motion-test.c
@@ -33,7 +33,6 @@
 #include "dsputil.h"
 #include "libavutil/lfg.h"
 
-#undef exit
 #undef printf
 
 #define WIDTH 64
@@ -61,7 +60,6 @@ static void help(void)
 {
     printf("motion-test [-h]\n"
            "test motion implementations\n");
-    exit(1);
 }
 
 static int64_t gettime(void)
@@ -138,7 +136,7 @@ int main(int argc, char **argv)
         switch(c) {
         case 'h':
             help();
-            break;
+            return 1;
         }
     }
 
diff --git a/libavformat/output-example.c b/libavformat/output-example.c
index 95690f7..809e236 100644
--- a/libavformat/output-example.c
+++ b/libavformat/output-example.c
@@ -445,7 +445,7 @@ int main(int argc, char **argv)
                "The output format is automatically guessed according to the file extension.\n"
                "Raw images can also be output by using '%%d' in the filename\n"
                "\n", argv[0]);
-        exit(1);
+        return 1;
     }
 
     filename = argv[1];
@@ -459,14 +459,14 @@ int main(int argc, char **argv)
     }
     if (!fmt) {
         fprintf(stderr, "Could not find suitable output format\n");
-        exit(1);
+        return 1;
     }
 
     /* allocate the output media context */
     oc = avformat_alloc_context();
     if (!oc) {
         fprintf(stderr, "Memory error\n");
-        exit(1);
+        return 1;
     }
     oc->oformat = fmt;
     snprintf(oc->filename, sizeof(oc->filename), "%s", filename);
@@ -486,7 +486,7 @@ int main(int argc, char **argv)
        parameters). */
     if (av_set_parameters(oc, NULL) < 0) {
         fprintf(stderr, "Invalid output format parameters\n");
-        exit(1);
+        return 1;
     }
 
     av_dump_format(oc, 0, filename, 1);
@@ -502,7 +502,7 @@ int main(int argc, char **argv)
     if (!(fmt->flags & AVFMT_NOFILE)) {
         if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0) {
             fprintf(stderr, "Could not open '%s'\n", filename);
-            exit(1);
+            return 1;
         }
     }
 
diff --git a/libavformat/seek-test.c b/libavformat/seek-test.c
index 363be8a..43dee56 100644
--- a/libavformat/seek-test.c
+++ b/libavformat/seek-test.c
@@ -28,7 +28,6 @@
 #include "libavutil/mathematics.h"
 #include "libavformat/avformat.h"
 
-#undef exit
 #undef printf
 #undef fprintf
 
@@ -75,7 +74,7 @@ int main(int argc, char **argv)
     if (argc != 2) {
         printf("usage: %s input_file\n"
                "\n", argv[0]);
-        exit(1);
+        return 1;
     }
 
     filename = argv[1];
@@ -84,13 +83,13 @@ int main(int argc, char **argv)
     av_dict_free(&format_opts);
     if (ret < 0) {
         fprintf(stderr, "cannot open %s\n", filename);
-        exit(1);
+        return 1;
     }
 
     ret = avformat_find_stream_info(ic, NULL);
     if (ret < 0) {
         fprintf(stderr, "%s: could not find codec parameters\n", filename);
-        exit(1);
+        return 1;
     }
 
     for(i=0; ; i++){
diff --git a/tools/cws2fws.c b/tools/cws2fws.c
index b8535fe..35fce35 100644
--- a/tools/cws2fws.c
+++ b/tools/cws2fws.c
@@ -29,14 +29,14 @@ int main(int argc, char *argv[])
     if (argc < 3)
     {
         printf("Usage: %s <infile.swf> <outfile.swf>\n", argv[0]);
-        exit(1);
+        return 1;
     }
 
     fd_in = open(argv[1], O_RDONLY);
     if (fd_in < 0)
     {
         perror("Error opening input file");
-        exit(1);
+        return 1;
     }
 
     fd_out = open(argv[2], O_WRONLY|O_CREAT, 00644);
@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
     {
         perror("Error opening output file");
         close(fd_in);
-        exit(1);
+        return 1;
     }
 
     if (read(fd_in, &buf_in, 8) != 8)
@@ -52,13 +52,13 @@ int main(int argc, char *argv[])
         printf("Header error\n");
         close(fd_in);
         close(fd_out);
-        exit(1);
+        return 1;
     }
 
     if (buf_in[0] != 'C' || buf_in[1] != 'W' || buf_in[2] != 'S')
     {
         printf("Not a compressed flash file\n");
-        exit(1);
+        return 1;
     }
 
     fstat(fd_in, &statbuf);
@@ -71,7 +71,7 @@ int main(int argc, char *argv[])
     buf_in[0] = 'F';
     if (write(fd_out, &buf_in, 8) < 8) {
         perror("Error writing output file");
-        exit(1);
+        return 1;
     }
 
     zstream.zalloc = NULL;
@@ -97,7 +97,7 @@ int main(int argc, char *argv[])
         {
             printf("Error while decompressing: %d\n", ret);
             inflateEnd(&zstream);
-            exit(1);
+            return 1;
         }
 
         dbgprintf("a_in: %d t_in: %lu a_out: %d t_out: %lu -- %lu out\n",
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
 
         if (write(fd_out, &buf_out, zstream.total_out - last_out) < zstream.total_out - last_out) {
             perror("Error writing output file");
-            exit(1);
+            return 1;
         }
 
         i += len;
@@ -128,7 +128,7 @@ int main(int argc, char *argv[])
         lseek(fd_out, 4, SEEK_SET);
         if (write(fd_out, &buf_in, 4) < 4) {
             perror("Error writing output file");
-            exit(1);
+            return 1;
         }
     }
 



More information about the ffmpeg-cvslog mailing list