On Thu, 13 Aug 2020, James Almer wrote:

On 8/13/2020 3:51 AM, Xu Guangxin wrote:

+
+    ret = obu_prefetch(s, header, MAX_OBU_HEADER_SIZE);
+    if (!ret)
+        return AVERROR(EOF);

We use AVERROR_EOF rather than AVERROR(EOF) (Afair, it was done because
EOF is not portable, but don't quote me on it).

Actually, it's a more severe thing than that.

AVERROR() is used for mapping an errno style error code, EINVAL etc, which can be either positive or negative numbers depending on platforms, to the AVERROR range (which is negative numbers).

So AVERROR() actually is shorthand for ERRNO_CODE_TO_AVERROR(). On platforms where errno codes are positive (most common modern platforms except BeOS/Haiku, iirc), it's essentially defined as (-(x)).

Now EOF isn't an errno error code, and is defined to be a negative value (often -1). So if you do AVERROR(EOF) on a system where errno codes are positive, AVERROR(EOF) evalues to +1, which most caller would identify as not an error at all.

TL;DR: AVERROR(EOF) is never correct.

// Martin

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to