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

pull/2/head
Diego Biurrun 13 years ago
parent be0675ce67
commit 9a5d6c23c5
  1. 5
      libavcodec/fft-test.c
  2. 4
      libavcodec/motion-test.c
  3. 10
      libavformat/output-example.c
  4. 7
      libavformat/seek-test.c
  5. 18
      tools/cws2fws.c

@ -37,8 +37,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#undef exit
/* reference fft */ /* reference fft */
#define MUL16(a,b) ((a) * (b)) #define MUL16(a,b) ((a) * (b))
@ -228,7 +226,6 @@ static void help(void)
"-n b set the transform size to 2^b\n" "-n b set the transform size to 2^b\n"
"-f x set scale factor for output data of (I)MDCT to x\n" "-f x set scale factor for output data of (I)MDCT to x\n"
); );
exit(1);
} }
enum tf_transform { enum tf_transform {
@ -267,7 +264,7 @@ int main(int argc, char **argv)
switch(c) { switch(c) {
case 'h': case 'h':
help(); help();
break; return 1;
case 's': case 's':
do_speed = 1; do_speed = 1;
break; break;

@ -33,7 +33,6 @@
#include "dsputil.h" #include "dsputil.h"
#include "libavutil/lfg.h" #include "libavutil/lfg.h"
#undef exit
#undef printf #undef printf
#define WIDTH 64 #define WIDTH 64
@ -61,7 +60,6 @@ static void help(void)
{ {
printf("motion-test [-h]\n" printf("motion-test [-h]\n"
"test motion implementations\n"); "test motion implementations\n");
exit(1);
} }
static int64_t gettime(void) static int64_t gettime(void)
@ -138,7 +136,7 @@ int main(int argc, char **argv)
switch(c) { switch(c) {
case 'h': case 'h':
help(); help();
break; return 1;
} }
} }

@ -445,7 +445,7 @@ int main(int argc, char **argv)
"The output format is automatically guessed according to the file extension.\n" "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" "Raw images can also be output by using '%%d' in the filename\n"
"\n", argv[0]); "\n", argv[0]);
exit(1); return 1;
} }
filename = argv[1]; filename = argv[1];
@ -459,14 +459,14 @@ int main(int argc, char **argv)
} }
if (!fmt) { if (!fmt) {
fprintf(stderr, "Could not find suitable output format\n"); fprintf(stderr, "Could not find suitable output format\n");
exit(1); return 1;
} }
/* allocate the output media context */ /* allocate the output media context */
oc = avformat_alloc_context(); oc = avformat_alloc_context();
if (!oc) { if (!oc) {
fprintf(stderr, "Memory error\n"); fprintf(stderr, "Memory error\n");
exit(1); return 1;
} }
oc->oformat = fmt; oc->oformat = fmt;
snprintf(oc->filename, sizeof(oc->filename), "%s", filename); snprintf(oc->filename, sizeof(oc->filename), "%s", filename);
@ -486,7 +486,7 @@ int main(int argc, char **argv)
parameters). */ parameters). */
if (av_set_parameters(oc, NULL) < 0) { if (av_set_parameters(oc, NULL) < 0) {
fprintf(stderr, "Invalid output format parameters\n"); fprintf(stderr, "Invalid output format parameters\n");
exit(1); return 1;
} }
av_dump_format(oc, 0, filename, 1); av_dump_format(oc, 0, filename, 1);
@ -502,7 +502,7 @@ int main(int argc, char **argv)
if (!(fmt->flags & AVFMT_NOFILE)) { if (!(fmt->flags & AVFMT_NOFILE)) {
if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0) { if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0) {
fprintf(stderr, "Could not open '%s'\n", filename); fprintf(stderr, "Could not open '%s'\n", filename);
exit(1); return 1;
} }
} }

@ -28,7 +28,6 @@
#include "libavutil/mathematics.h" #include "libavutil/mathematics.h"
#include "libavformat/avformat.h" #include "libavformat/avformat.h"
#undef exit
#undef printf #undef printf
#undef fprintf #undef fprintf
@ -75,7 +74,7 @@ int main(int argc, char **argv)
if (argc != 2) { if (argc != 2) {
printf("usage: %s input_file\n" printf("usage: %s input_file\n"
"\n", argv[0]); "\n", argv[0]);
exit(1); return 1;
} }
filename = argv[1]; filename = argv[1];
@ -84,13 +83,13 @@ int main(int argc, char **argv)
av_dict_free(&format_opts); av_dict_free(&format_opts);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "cannot open %s\n", filename); fprintf(stderr, "cannot open %s\n", filename);
exit(1); return 1;
} }
ret = avformat_find_stream_info(ic, NULL); ret = avformat_find_stream_info(ic, NULL);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "%s: could not find codec parameters\n", filename); fprintf(stderr, "%s: could not find codec parameters\n", filename);
exit(1); return 1;
} }
for(i=0; ; i++){ for(i=0; ; i++){

@ -29,14 +29,14 @@ int main(int argc, char *argv[])
if (argc < 3) if (argc < 3)
{ {
printf("Usage: %s <infile.swf> <outfile.swf>\n", argv[0]); printf("Usage: %s <infile.swf> <outfile.swf>\n", argv[0]);
exit(1); return 1;
} }
fd_in = open(argv[1], O_RDONLY); fd_in = open(argv[1], O_RDONLY);
if (fd_in < 0) if (fd_in < 0)
{ {
perror("Error opening input file"); perror("Error opening input file");
exit(1); return 1;
} }
fd_out = open(argv[2], O_WRONLY|O_CREAT, 00644); 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"); perror("Error opening output file");
close(fd_in); close(fd_in);
exit(1); return 1;
} }
if (read(fd_in, &buf_in, 8) != 8) if (read(fd_in, &buf_in, 8) != 8)
@ -52,13 +52,13 @@ int main(int argc, char *argv[])
printf("Header error\n"); printf("Header error\n");
close(fd_in); close(fd_in);
close(fd_out); close(fd_out);
exit(1); return 1;
} }
if (buf_in[0] != 'C' || buf_in[1] != 'W' || buf_in[2] != 'S') if (buf_in[0] != 'C' || buf_in[1] != 'W' || buf_in[2] != 'S')
{ {
printf("Not a compressed flash file\n"); printf("Not a compressed flash file\n");
exit(1); return 1;
} }
fstat(fd_in, &statbuf); fstat(fd_in, &statbuf);
@ -71,7 +71,7 @@ int main(int argc, char *argv[])
buf_in[0] = 'F'; buf_in[0] = 'F';
if (write(fd_out, &buf_in, 8) < 8) { if (write(fd_out, &buf_in, 8) < 8) {
perror("Error writing output file"); perror("Error writing output file");
exit(1); return 1;
} }
zstream.zalloc = NULL; zstream.zalloc = NULL;
@ -97,7 +97,7 @@ int main(int argc, char *argv[])
{ {
printf("Error while decompressing: %d\n", ret); printf("Error while decompressing: %d\n", ret);
inflateEnd(&zstream); inflateEnd(&zstream);
exit(1); return 1;
} }
dbgprintf("a_in: %d t_in: %lu a_out: %d t_out: %lu -- %lu out\n", 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) { if (write(fd_out, &buf_out, zstream.total_out - last_out) < zstream.total_out - last_out) {
perror("Error writing output file"); perror("Error writing output file");
exit(1); return 1;
} }
i += len; i += len;
@ -128,7 +128,7 @@ int main(int argc, char *argv[])
lseek(fd_out, 4, SEEK_SET); lseek(fd_out, 4, SEEK_SET);
if (write(fd_out, &buf_in, 4) < 4) { if (write(fd_out, &buf_in, 4) < 4) {
perror("Error writing output file"); perror("Error writing output file");
exit(1); return 1;
} }
} }

Loading…
Cancel
Save