[FFmpeg-cvslog] ffmpeg_opt: get_preset_file_2(): fix avio_open2() return code check

Timothy Gu git at videolan.org
Tue Feb 25 00:11:16 CET 2014


ffmpeg | branch: master | Timothy Gu <timothygu99 at gmail.com> | Mon Feb 24 02:19:55 2014 +0000| [774239be717150909219ad2c0696bfb6a50cf2cb] | committer: Michael Niedermayer

ffmpeg_opt: get_preset_file_2(): fix avio_open2() return  code check

avio_open2() only return < 0 when error.

Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 ffmpeg_opt.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 7b4630f..7bd0817 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -978,14 +978,14 @@ static uint8_t *get_line(AVIOContext *s)
 
 static int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOContext **s)
 {
-    int i, ret = 1;
+    int i, ret = -1;
     char filename[1000];
     const char *base[3] = { getenv("AVCONV_DATADIR"),
                             getenv("HOME"),
                             AVCONV_DATADIR,
                             };
 
-    for (i = 0; i < FF_ARRAY_ELEMS(base) && ret; i++) {
+    for (i = 0; i < FF_ARRAY_ELEMS(base) && ret < 0; i++) {
         if (!base[i])
             continue;
         if (codec_name) {
@@ -993,7 +993,7 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV
                      i != 1 ? "" : "/.avconv", codec_name, preset_name);
             ret = avio_open2(s, filename, AVIO_FLAG_READ, &int_cb, NULL);
         }
-        if (ret) {
+        if (ret < 0) {
             snprintf(filename, sizeof(filename), "%s%s/%s.avpreset", base[i],
                      i != 1 ? "" : "/.avconv", preset_name);
             ret = avio_open2(s, filename, AVIO_FLAG_READ, &int_cb, NULL);



More information about the ffmpeg-cvslog mailing list