[FFmpeg-devel] avformat/http: add string of the error when only return error number

Submitted by Steven Liu on July 1, 2019, 7:27 a.m.

Details

Message ID 20190701072700.74944-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Steven Liu July 1, 2019, 7:27 a.m.
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/http.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nicolas George July 1, 2019, 7:47 a.m.
Steven Liu (12019-07-01):
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/http.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Any reason to leave the nummeric code at all?

Regards,
Steven Liu July 1, 2019, 8:29 a.m.
> 在 2019年7月1日,下午3:47,Nicolas George <george@nsup.org> 写道:
> 
> Steven Liu (12019-07-01):
>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
>> ---
>> libavformat/http.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Any reason to leave the nummeric code at all?
Just leave the old numeric code to some people like it. I think the better to remove it, but i cannot sure if that is useful to other people :D.

Thanks

Steven
Nicolas George July 1, 2019, 8:49 a.m.
Liu Steven (12019-07-01):
> Just leave the old numeric code to some people like it. I think the
> better to remove it, but i cannot sure if that is useful to other
> people :D.

Many places only print the error message. I see no difference specific
to this specific place.

Regards,
Steven Liu July 1, 2019, 8:55 a.m.
> 在 2019年7月1日,下午4:49,Nicolas George <george@nsup.org> 写道:
> 
> Liu Steven (12019-07-01):
>> Just leave the old numeric code to some people like it. I think the
>> better to remove it, but i cannot sure if that is useful to other
>> people :D.
> 
> Many places only print the error message. I see no difference specific
> to this specific place.
Agreed, but string is looks easier to understand than numeric code.

For example:
    When i debug the code: it give me message:

    [http @ 0x7ff64540c200] URL read error:  -541478725
    after patch:
    [http @ 0x7ff64540c200] URL read error:  End of file

I think the message after patch is easier to understand :D
Thanks
Steven.
Nicolas George July 1, 2019, 9:45 a.m.
Liu Steven (12019-07-01):
> For example:
>     When i debug the code: it give me message:
> 
>     [http @ 0x7ff64540c200] URL read error:  -541478725
>     after patch:
>     [http @ 0x7ff64540c200] URL read error:  End of file
> 
> I think the message after patch is easier to understand :D

I do not understand what you are saying now. With your patch, I think
the message would appear:
	
[http @ 0x7ff64540c200] URL read error:  (-541478725)End of file

And I do not think the -541478725 brings any good.

Regards,
Steven Liu July 1, 2019, 9:45 a.m.
> 在 2019年7月1日,下午4:49,Nicolas George <george@nsup.org> 写道:
> 
> Liu Steven (12019-07-01):
>> Just leave the old numeric code to some people like it. I think the
>> better to remove it, but i cannot sure if that is useful to other
>> people :D.
> 
> Many places only print the error message. I see no difference specific
> to this specific place.

Patch update: https://patchwork.ffmpeg.org/patch/13787/
> 
> Regards,
> 
> -- 
>  Nicolas George

Patch hide | download patch | download mbox

diff --git a/libavformat/http.c b/libavformat/http.c
index 5a937994cf..1ee4d5189c 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1638,7 +1638,7 @@  static int http_shutdown(URLContext *h, int flags)
             read_ret = ffurl_read(s->hd, buf, sizeof(buf));
             s->hd->flags &= ~AVIO_FLAG_NONBLOCK;
             if (read_ret < 0 && read_ret != AVERROR(EAGAIN)) {
-                av_log(h, AV_LOG_ERROR, "URL read error:  %d\n", read_ret);
+                av_log(h, AV_LOG_ERROR, "URL read error:  %d(%s)\n", read_ret, av_err2str(read_ret));
                 ret = read_ret;
             }
         }