dv: Don't return EIO upon EOF

Message ID 20170219161525.19461-1-stebbins@jetheaddev.com
State New
Headers show

Commit Message

John Stebbins Feb. 19, 2017, 4:15 p.m.
---
 libavformat/dv.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Luca Barbato Feb. 19, 2017, 5:25 p.m. | #1
On 19/02/2017 17:15, John Stebbins wrote:
> ---
>  libavformat/dv.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/dv.c b/libavformat/dv.c
> index d4e5180..0cd60de 100644
> --- a/libavformat/dv.c
> +++ b/libavformat/dv.c
> @@ -484,11 +484,14 @@ static int dv_read_packet(AVFormatContext *s, AVPacket *pkt)
>      size = avpriv_dv_get_packet(c->dv_demux, pkt);
>  
>      if (size < 0) {
> +        int result;
> +
>          if (!c->dv_demux->sys)
>              return AVERROR(EIO);
>          size = c->dv_demux->sys->frame_size;
> -        if (avio_read(s->pb, c->buf, size) <= 0)
> -            return AVERROR(EIO);
> +        result = avio_read(s->pb, c->buf, size);
> +        if (result <= 0)
> +            return result;
>  
>          size = avpriv_dv_produce_packet(c->dv_demux, pkt, c->buf, size);
>      }
> 

Probably it is a stable candidate.

nit: `ret` is the name normally used across the codebase for the
variable instead of result.

lu
John Stebbins Feb. 19, 2017, 10:02 p.m. | #2
On 02/19/2017 10:25 AM, Luca Barbato wrote:
> On 19/02/2017 17:15, John Stebbins wrote:
>> ---
>>  libavformat/dv.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavformat/dv.c b/libavformat/dv.c
>> index d4e5180..0cd60de 100644
>> --- a/libavformat/dv.c
>> +++ b/libavformat/dv.c
>> @@ -484,11 +484,14 @@ static int dv_read_packet(AVFormatContext *s, AVPacket *pkt)
>>      size = avpriv_dv_get_packet(c->dv_demux, pkt);
>>  
>>      if (size < 0) {
>> +        int result;
>> +
>>          if (!c->dv_demux->sys)
>>              return AVERROR(EIO);
>>          size = c->dv_demux->sys->frame_size;
>> -        if (avio_read(s->pb, c->buf, size) <= 0)
>> -            return AVERROR(EIO);
>> +        result = avio_read(s->pb, c->buf, size);
>> +        if (result <= 0)
>> +            return result;
>>  
>>          size = avpriv_dv_produce_packet(c->dv_demux, pkt, c->buf, size);
>>      }
>>
> Probably it is a stable candidate.
>
> nit: `ret` is the name normally used across the codebase for the
> variable instead of result.
>
>

Yes, it would be nice for this to go into stable. result changed to ret locally.

May I push?
Luca Barbato Feb. 20, 2017, 2:39 a.m. | #3
On 19/02/2017 23:02, John Stebbins wrote:
> On 02/19/2017 10:25 AM, Luca Barbato wrote:
>> On 19/02/2017 17:15, John Stebbins wrote:
>>> ---
>>>  libavformat/dv.c | 7 +++++--
>>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libavformat/dv.c b/libavformat/dv.c
>>> index d4e5180..0cd60de 100644
>>> --- a/libavformat/dv.c
>>> +++ b/libavformat/dv.c
>>> @@ -484,11 +484,14 @@ static int dv_read_packet(AVFormatContext *s, AVPacket *pkt)
>>>      size = avpriv_dv_get_packet(c->dv_demux, pkt);
>>>  
>>>      if (size < 0) {
>>> +        int result;
>>> +
>>>          if (!c->dv_demux->sys)
>>>              return AVERROR(EIO);
>>>          size = c->dv_demux->sys->frame_size;
>>> -        if (avio_read(s->pb, c->buf, size) <= 0)
>>> -            return AVERROR(EIO);
>>> +        result = avio_read(s->pb, c->buf, size);
>>> +        if (result <= 0)
>>> +            return result;
>>>  
>>>          size = avpriv_dv_produce_packet(c->dv_demux, pkt, c->buf, size);
>>>      }
>>>
>> Probably it is a stable candidate.
>>
>> nit: `ret` is the name normally used across the codebase for the
>> variable instead of result.
>>
>>
> 
> Yes, it would be nice for this to go into stable. result changed to ret locally.
> 
> May I push?
> 

Sure :)

Patch

diff --git a/libavformat/dv.c b/libavformat/dv.c
index d4e5180..0cd60de 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -484,11 +484,14 @@  static int dv_read_packet(AVFormatContext *s, AVPacket *pkt)
     size = avpriv_dv_get_packet(c->dv_demux, pkt);
 
     if (size < 0) {
+        int result;
+
         if (!c->dv_demux->sys)
             return AVERROR(EIO);
         size = c->dv_demux->sys->frame_size;
-        if (avio_read(s->pb, c->buf, size) <= 0)
-            return AVERROR(EIO);
+        result = avio_read(s->pb, c->buf, size);
+        if (result <= 0)
+            return result;
 
         size = avpriv_dv_produce_packet(c->dv_demux, pkt, c->buf, size);
     }