diff mbox series

[FFmpeg-devel,v2,1/2] avformat/network: Return a proper negative error code from ff_network_init()

Message ID 20240419172309.101782-1-ffmpeg-devel@pileofstuff.org
State New
Headers show
Series [FFmpeg-devel,v2,1/2] avformat/network: Return a proper negative error code from ff_network_init() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andrew Sayers April 19, 2024, 5:23 p.m. UTC
---
 libavformat/network.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Almer April 19, 2024, 5:37 p.m. UTC | #1
On 4/19/2024 2:23 PM, Andrew Sayers wrote:
> ---
>   libavformat/network.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/network.c b/libavformat/network.c
> index f752efc411..d518bb0541 100644
> --- a/libavformat/network.c
> +++ b/libavformat/network.c
> @@ -63,7 +63,7 @@ int ff_network_init(void)
>       if (WSAStartup(MAKEWORD(1,1), &wsaData))
>           return 0;
>   #endif
> -    return 1;
> +    return -1;

This will make avformat_network_init() fail on all targets but Windows. 
Also, there are a lot of ff_network_init() callers that check for 0 as 
failure and anything else as success.

What needs to be done is to make ff_network_init() return ff_neterrno() 
on WSAStartup() failure and 0 on success on Windows, and 0 for every 
other target (where there's no chance of failure), and the callers be 
adapted to check for < 0 and propagate the returned error value if so.

>   }
>   
>   int ff_network_wait_fd(int fd, int write)
diff mbox series

Patch

diff --git a/libavformat/network.c b/libavformat/network.c
index f752efc411..d518bb0541 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -63,7 +63,7 @@  int ff_network_init(void)
     if (WSAStartup(MAKEWORD(1,1), &wsaData))
         return 0;
 #endif
-    return 1;
+    return -1;
 }
 
 int ff_network_wait_fd(int fd, int write)