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 30E604ABEA for ; Thu, 16 May 2024 09:34:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6C5B968D586; Thu, 16 May 2024 12:34:17 +0300 (EEST) Received: from b-painless.mh.aa.net.uk (b-painless.mh.aa.net.uk [81.187.30.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B506468D47E for ; Thu, 16 May 2024 12:34:06 +0300 (EEST) Received: from 0.b.4.b.7.4.0.8.c.4.a.5.d.8.b.2.0.5.8.0.9.1.8.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:819:850:2b8d:5a4c:8047:b4b0] helo=andrews-2024-laptop.lan) by painless-b.tch.aa.net.uk with esmtp (Exim 4.96) (envelope-from ) id 1s7XV0-002QR7-00; Thu, 16 May 2024 10:34:06 +0100 From: Andrew Sayers To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 May 2024 10:33:36 +0100 Message-ID: <20240516093403.3763258-4-ffmpeg-devel@pileofstuff.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240516093403.3763258-1-ffmpeg-devel@pileofstuff.org> References: <94b3be81-0777-fbc1-8ba8-a39a8f6397d4@passwd.hu> <20240516093403.3763258-1-ffmpeg-devel@pileofstuff.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 3/5] avformat/network: add ff_neterror2() for cases where we already have an error 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 Cc: Andrew Sayers 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: For example, WSAStartup()'s documentation says: "A call to the WSAGetLastError function is not needed and should not be used" --- libavformat/network.c | 5 ++++- libavformat/network.h | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libavformat/network.c b/libavformat/network.c index 5d0d05c5f1..351dc34bb6 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -123,7 +123,10 @@ void ff_network_close(void) #if HAVE_WINSOCK2_H int ff_neterror(void) { - int err = WSAGetLastError(); + return ff_neterror2(WSAGetLastError()); +} +int ff_neterror2(int err) +{ switch (err) { case WSAEWOULDBLOCK: return AVERROR(EAGAIN); diff --git a/libavformat/network.h b/libavformat/network.h index f338694212..7c8f81a050 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -63,6 +63,12 @@ * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) */ int ff_neterror(void); +/* + * @brief ff_neterror()-style AVERROR + * @param err error code (usually an errno or Windows Sockets Error Code) + * @note Windows Sockets Error Codes are only supported in Windows + */ +int ff_neterror2(int err); #else #include #include @@ -76,6 +82,12 @@ int ff_neterror(void); * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) */ #define ff_neterror() AVERROR(errno) +/* + * @brief ff_neterror()-style AVERROR + * @param err error code (usually an errno or Windows Sockets Error Code) + * @note Windows Sockets Error Codes are only supported in Windows + */ +#define ff_neterror2(ERRNO) AVERROR(ERRNO) #endif /* HAVE_WINSOCK2_H */ #if HAVE_ARPA_INET_H -- 2.43.0 _______________________________________________ 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".