From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 500BC4A9ED for ; Tue, 7 May 2024 13:13:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1504968D6E1; Tue, 7 May 2024 16:13:06 +0300 (EEST) Received: from alt2.a-painless.mh.aa.net.uk (alt2.a-painless.mh.aa.net.uk [81.187.30.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 52B3F68D2D2 for ; Tue, 7 May 2024 16:12:59 +0300 (EEST) Received: from 4.b.1.2.5.3.2.f.2.f.3.9.e.5.e.4.0.5.8.0.9.1.8.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:819:850:4e5e:93f2:f235:21b4] helo=andrews-2024-laptop.sayers) by painless-a.thn.aa.net.uk with smtp (Exim 4.96) (envelope-from ) id 1s4Kcs-0067LD-2f for ffmpeg-devel@ffmpeg.org; Tue, 07 May 2024 14:12:58 +0100 Date: Tue, 7 May 2024 14:12:51 +0100 From: Andrew Sayers To: FFmpeg development discussions and patches Message-ID: References: <20240420132501.273495-1-ffmpeg-devel@pileofstuff.org> <20240420132501.273495-2-ffmpeg-devel@pileofstuff.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH v4 2/3] avformat/network: Return 0/AVERROR from ff_network_init() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sun, May 05, 2024 at 10:05:36PM +0200, Marton Balint wrote: > > > On Sat, 20 Apr 2024, Andrew Sayers wrote: > > > --- > > libavformat/avio.c | 4 ++-- > > libavformat/network.c | 7 +++---- > > libavformat/rtsp.c | 12 ++++++------ > > libavformat/rtspdec.c | 4 ++-- > > libavformat/sapdec.c | 4 ++-- > > libavformat/sapenc.c | 4 ++-- > > 6 files changed, 17 insertions(+), 18 deletions(-) > > > > diff --git a/libavformat/avio.c b/libavformat/avio.c > > index d109f3adff..f82edec779 100644 > > --- a/libavformat/avio.c > > +++ b/libavformat/avio.c > > @@ -123,8 +123,8 @@ static int url_alloc_for_protocol(URLContext **puc, const URLProtocol *up, > > int err; > > > > #if CONFIG_NETWORK > > - if (up->flags & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init()) > > - return AVERROR(EIO); > > + if (up->flags & URL_PROTOCOL_FLAG_NETWORK && (err=ff_network_init())<0) > > + return err; > > #endif > > if ((flags & AVIO_FLAG_READ) && !up->url_read) { > > av_log(NULL, AV_LOG_ERROR, > > diff --git a/libavformat/network.c b/libavformat/network.c > > index f295957aa5..c1b0e69362 100644 > > --- a/libavformat/network.c > > +++ b/libavformat/network.c > > @@ -59,11 +59,10 @@ int ff_network_init(void) > > { > > #if HAVE_WINSOCK2_H > > WSADATA wsaData; > > - > > - if (WSAStartup(MAKEWORD(1,1), &wsaData)) > > - return 0; > > + return ff_neterrno2(WSAStartup(MAKEWORD(1,1), &wsaData)); > > +#else > > + return 0; > > #endif > > - return 1; > > } > > > > int ff_network_wait_fd(int fd, int write) > > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c > > index b0c61ee00a..3db4ed11c2 100644 > > --- a/libavformat/rtsp.c > > +++ b/libavformat/rtsp.c > > @@ -1740,8 +1740,8 @@ int ff_rtsp_connect(AVFormatContext *s) > > return AVERROR(EINVAL); > > } > > > > - if (!ff_network_init()) > > - return AVERROR(EIO); > > + if ((err = ff_network_init())<0) > > + return err; > > Assignments in if conditions should be avoided. So this should be expanded > to: > > err = ff_network_init(); > if (err < 0) > return err; > > Same for the rest of the checks later. > > Thanks, > Marton Assignments in if conditions seem to be the standard in that file, so I figured it was better to have one ugly standard than two competing ones. But I agree they're not good, so I'll propose a new patch in a few days if nobody objects. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".