OSDN Git Service

av_tempfile: fix error codes
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 16 Oct 2011 19:27:20 +0000 (21:27 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 16 Oct 2011 19:51:28 +0000 (21:51 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavutil/file.c

index e73e8ef..e2cfc2f 100644 (file)
@@ -146,7 +146,7 @@ int av_tempfile(const char *prefix, char **filename) {
     /* -----common section-----*/
     if (*filename == NULL) {
         av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n");
-        return -1;
+        return AVERROR(ENOMEM);
     }
 #if !HAVE_MKSTEMP
 #   ifndef O_BINARY
@@ -166,8 +166,9 @@ int av_tempfile(const char *prefix, char **filename) {
 #endif
     /* -----common section-----*/
     if (fd < 0) {
+        int err = AVERROR(errno);
         av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename);
-        return -1;
+        return err;
     }
     return fd; /* success */
 }