[FFmpeg-devel] [PATCH v5 2/6] Rename "ff_neterrno()" to "ff_neterror()"
Andrew Sayers
ffmpeg-devel at pileofstuff.org
Thu May 16 14:59:07 EEST 2024
This function does not check errno on Windows, so the old name was misleading.
Actual command:
sed -i -e 's/ff_neterrno/ff_neterror/g' $( git grep -l ff_neterrno )
---
libavformat/network.c | 24 ++++++++++++------------
libavformat/network.h | 4 ++--
libavformat/rtpproto.c | 8 ++++----
libavformat/sctp.c | 10 +++++-----
libavformat/tcp.c | 8 ++++----
libavformat/udp.c | 32 ++++++++++++++++----------------
libavformat/unix.c | 6 +++---
libavformat/url.h | 2 +-
8 files changed, 47 insertions(+), 47 deletions(-)
diff --git a/libavformat/network.c b/libavformat/network.c
index f752efc411..5d0d05c5f1 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -72,7 +72,7 @@ int ff_network_wait_fd(int fd, int write)
struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
int ret;
ret = poll(&p, 1, POLLING_TIME);
- return ret < 0 ? ff_neterrno() : p.revents & (ev | POLLERR | POLLHUP) ? 0 : AVERROR(EAGAIN);
+ return ret < 0 ? ff_neterror() : p.revents & (ev | POLLERR | POLLHUP) ? 0 : AVERROR(EAGAIN);
}
int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, AVIOInterruptCB *int_cb)
@@ -121,7 +121,7 @@ void ff_network_close(void)
}
#if HAVE_WINSOCK2_H
-int ff_neterrno(void)
+int ff_neterror(void)
{
int err = WSAGetLastError();
switch (err) {
@@ -168,7 +168,7 @@ static int ff_poll_interrupt(struct pollfd *p, nfds_t nfds, int timeout,
ret = poll(p, nfds, POLLING_TIME);
if (ret != 0) {
if (ret < 0)
- ret = ff_neterrno();
+ ret = ff_neterror();
if (ret == AVERROR(EINTR))
continue;
break;
@@ -217,11 +217,11 @@ int ff_listen(int fd, const struct sockaddr *addr,
}
ret = bind(fd, addr, addrlen);
if (ret)
- return ff_neterrno();
+ return ff_neterror();
ret = listen(fd, 1);
if (ret)
- return ff_neterrno();
+ return ff_neterror();
return ret;
}
@@ -236,7 +236,7 @@ int ff_accept(int fd, int timeout, URLContext *h)
ret = accept(fd, NULL, NULL);
if (ret < 0)
- return ff_neterrno();
+ return ff_neterror();
if (ff_socket_nonblock(ret, 1) < 0)
av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n");
@@ -267,7 +267,7 @@ int ff_listen_connect(int fd, const struct sockaddr *addr,
av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n");
while ((ret = connect(fd, addr, addrlen))) {
- ret = ff_neterrno();
+ ret = ff_neterror();
switch (ret) {
case AVERROR(EINTR):
if (ff_check_interrupt(&h->interrupt_callback))
@@ -280,7 +280,7 @@ int ff_listen_connect(int fd, const struct sockaddr *addr,
return ret;
optlen = sizeof(ret);
if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen))
- ret = AVUNERROR(ff_neterrno());
+ ret = AVUNERROR(ff_neterror());
if (ret != 0) {
char errbuf[100];
ret = AVERROR(ret);
@@ -365,7 +365,7 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt,
attempt->fd = ff_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol, h);
if (attempt->fd < 0)
- return ff_neterrno();
+ return ff_neterror();
attempt->deadline_us = av_gettime_relative() + timeout_ms * 1000;
attempt->addr = ai;
@@ -381,7 +381,7 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt,
}
while ((ret = connect(attempt->fd, ai->ai_addr, ai->ai_addrlen))) {
- ret = ff_neterrno();
+ ret = ff_neterror();
switch (ret) {
case AVERROR(EINTR):
if (ff_check_interrupt(&h->interrupt_callback)) {
@@ -478,7 +478,7 @@ int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address,
// a successful connection or an error).
optlen = sizeof(last_err);
if (getsockopt(attempts[i].fd, SOL_SOCKET, SO_ERROR, &last_err, &optlen))
- last_err = ff_neterrno();
+ last_err = ff_neterror();
else if (last_err != 0)
last_err = AVERROR(last_err);
if (last_err == 0) {
@@ -587,6 +587,6 @@ int ff_http_match_no_proxy(const char *no_proxy, const char *hostname)
void ff_log_net_error(void *ctx, int level, const char* prefix)
{
char errbuf[100];
- av_strerror(ff_neterrno(), errbuf, sizeof(errbuf));
+ av_strerror(ff_neterror(), errbuf, sizeof(errbuf));
av_log(ctx, level, "%s: %s\n", prefix, errbuf);
}
diff --git a/libavformat/network.h b/libavformat/network.h
index 728c20c9bb..f338694212 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -62,7 +62,7 @@
* @return platform-specific AVERROR value
* @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise)
*/
-int ff_neterrno(void);
+int ff_neterror(void);
#else
#include <sys/types.h>
#include <sys/socket.h>
@@ -75,7 +75,7 @@ int ff_neterrno(void);
* @return platform-specific AVERROR value
* @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise)
*/
-#define ff_neterrno() AVERROR(errno)
+#define ff_neterror() AVERROR(errno)
#endif /* HAVE_WINSOCK2_H */
#if HAVE_ARPA_INET_H
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index b1cdf061f0..e8963307f3 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -410,8 +410,8 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
len = recvfrom(p[i].fd, buf, size, 0,
(struct sockaddr *)addrs[i], addr_lens[i]);
if (len < 0) {
- if (ff_neterrno() == AVERROR(EAGAIN) ||
- ff_neterrno() == AVERROR(EINTR))
+ if (ff_neterror() == AVERROR(EAGAIN) ||
+ ff_neterror() == AVERROR(EINTR))
continue;
return AVERROR(EIO);
}
@@ -422,7 +422,7 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
} else if (n == 0 && h->rw_timeout > 0 && --runs <= 0) {
return AVERROR(ETIMEDOUT);
} else if (n < 0) {
- if (ff_neterrno() == AVERROR(EINTR))
+ if (ff_neterror() == AVERROR(EINTR))
continue;
return AVERROR(EIO);
}
@@ -492,7 +492,7 @@ static int rtp_write(URLContext *h, const uint8_t *buf, int size)
ret = sendto(fd, buf, size, 0, (struct sockaddr *) source,
*source_len);
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
if (RTP_PT_IS_RTCP(buf[1])) {
diff --git a/libavformat/sctp.c b/libavformat/sctp.c
index 9d9e90097e..7170a716e7 100644
--- a/libavformat/sctp.c
+++ b/libavformat/sctp.c
@@ -222,7 +222,7 @@ static int sctp_open(URLContext *h, const char *uri, int flags)
restart:
fd = ff_socket(cur_ai->ai_family, SOCK_STREAM, IPPROTO_SCTP, h);
if (fd < 0) {
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
@@ -261,7 +261,7 @@ restart:
av_log(h, AV_LOG_ERROR,
"SCTP ERROR: Unable to initialize socket max streams %d\n",
s->max_streams);
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail1;
}
}
@@ -296,7 +296,7 @@ static int sctp_wait_fd(int fd, int write)
int ret;
ret = poll(&p, 1, 100);
- return ret < 0 ? ff_neterrno() : p.revents & ev ? 0 : AVERROR(EAGAIN);
+ return ret < 0 ? ff_neterror() : p.revents & ev ? 0 : AVERROR(EAGAIN);
}
static int sctp_read(URLContext *h, uint8_t *buf, int size)
@@ -319,7 +319,7 @@ static int sctp_read(URLContext *h, uint8_t *buf, int size)
} else
ret = recv(s->fd, buf, size, 0);
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int sctp_write(URLContext *h, const uint8_t *buf, int size)
@@ -345,7 +345,7 @@ static int sctp_write(URLContext *h, const uint8_t *buf, int size)
} else
ret = send(s->fd, buf, size, MSG_NOSIGNAL);
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int sctp_close(URLContext *h)
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 755e3af242..2c12ee78ad 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -226,7 +226,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
cur_ai->ai_socktype,
cur_ai->ai_protocol, h);
if (fd < 0) {
- ret = ff_neterrno();
+ ret = ff_neterror();
cur_ai = cur_ai->ai_next;
}
}
@@ -296,7 +296,7 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size)
ret = recv(s->fd, buf, size, 0);
if (ret == 0)
return AVERROR_EOF;
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int tcp_write(URLContext *h, const uint8_t *buf, int size)
@@ -310,7 +310,7 @@ static int tcp_write(URLContext *h, const uint8_t *buf, int size)
return ret;
}
ret = send(s->fd, buf, size, MSG_NOSIGNAL);
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int tcp_shutdown(URLContext *h, int flags)
@@ -357,7 +357,7 @@ static int tcp_get_window_size(URLContext *h)
#endif
if (getsockopt(s->fd, SOL_SOCKET, SO_RCVBUF, &avail, &avail_len)) {
- return ff_neterrno();
+ return ff_neterror();
}
return avail;
}
diff --git a/libavformat/udp.c b/libavformat/udp.c
index c1ebdd1222..aca3ed9ceb 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -190,7 +190,7 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt(IPV4/IPV6 MULTICAST TTL)");
if (setsockopt(sockfd, protocol, cmd, &ttl, sizeof(ttl)) < 0) {
ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 MULTICAST TTL)");
- return ff_neterrno();
+ return ff_neterror();
}
}
@@ -211,7 +211,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr,
mreq.imr_interface.s_addr = INADDR_ANY;
if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) {
ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP)");
- return ff_neterrno();
+ return ff_neterror();
}
}
#endif
@@ -224,7 +224,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr,
mreq6.ipv6mr_interface = 0;
if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) {
ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP)");
- return ff_neterrno();
+ return ff_neterror();
}
}
#endif
@@ -294,7 +294,7 @@ static int udp_set_multicast_sources(URLContext *h,
ff_log_net_error(h, AV_LOG_ERROR, "setsockopt(MCAST_JOIN_SOURCE_GROUP)");
else
ff_log_net_error(h, AV_LOG_ERROR, "setsockopt(MCAST_BLOCK_SOURCE)");
- return ff_neterrno();
+ return ff_neterror();
}
}
return 0;
@@ -326,7 +326,7 @@ static int udp_set_multicast_sources(URLContext *h,
ff_log_net_error(h, AV_LOG_ERROR, "setsockopt(IP_ADD_SOURCE_MEMBERSHIP)");
else
ff_log_net_error(h, AV_LOG_ERROR, "setsockopt(IP_BLOCK_SOURCE)");
- return ff_neterrno();
+ return ff_neterror();
}
}
#else
@@ -508,8 +508,8 @@ static void *circular_buffer_task_rx( void *_URLContext)
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_cancelstate);
pthread_mutex_lock(&s->mutex);
if (len < 0) {
- if (ff_neterrno() != AVERROR(EAGAIN) && ff_neterrno() != AVERROR(EINTR)) {
- s->circular_buffer_error = ff_neterrno();
+ if (ff_neterror() != AVERROR(EAGAIN) && ff_neterror() != AVERROR(EINTR)) {
+ s->circular_buffer_error = ff_neterror();
goto end;
}
continue;
@@ -621,7 +621,7 @@ static void *circular_buffer_task_tx( void *_URLContext)
len -= ret;
p += ret;
} else {
- ret = ff_neterrno();
+ ret = ff_neterror();
if (ret != AVERROR(EAGAIN) && ret != AVERROR(EINTR)) {
pthread_mutex_lock(&s->mutex);
s->circular_buffer_error = ret;
@@ -797,7 +797,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if (s->reuse_socket > 0 || (s->is_multicast && s->reuse_socket < 0)) {
s->reuse_socket = 1;
if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0) {
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
}
@@ -805,7 +805,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if (s->is_broadcast) {
#ifdef SO_BROADCAST
if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), sizeof(s->is_broadcast)) != 0) {
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
#else
@@ -829,7 +829,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if (dscp >= 0) {
dscp <<= 2;
if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) != 0) {
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
}
@@ -846,7 +846,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
/* the bind is needed to give a port to the socket now */
if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) {
ff_log_net_error(h, AV_LOG_ERROR, "bind failed");
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
@@ -890,7 +890,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) {
ff_log_net_error(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF)");
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
} else {
@@ -914,7 +914,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if (s->is_connected) {
if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {
ff_log_net_error(h, AV_LOG_ERROR, "connect");
- ret = ff_neterrno();
+ ret = ff_neterror();
goto fail;
}
}
@@ -1045,7 +1045,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
}
ret = recvfrom(s->udp_fd, buf, size, 0, (struct sockaddr *)&addr, &addr_len);
if (ret < 0)
- return ff_neterrno();
+ return ff_neterror();
if (ff_ip_check_source_lists(&addr, &s->filters))
return AVERROR(EINTR);
return ret;
@@ -1098,7 +1098,7 @@ static int udp_write(URLContext *h, const uint8_t *buf, int size)
} else
ret = send(s->udp_fd, buf, size, 0);
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int udp_close(URLContext *h)
diff --git a/libavformat/unix.c b/libavformat/unix.c
index 5704155cf0..d1b4e6a5ca 100644
--- a/libavformat/unix.c
+++ b/libavformat/unix.c
@@ -70,7 +70,7 @@ static int unix_open(URLContext *h, const char *filename, int flags)
av_strlcpy(s->addr.sun_path, filename, sizeof(s->addr.sun_path));
if ((fd = ff_socket(AF_UNIX, s->type, 0, h)) < 0)
- return ff_neterrno();
+ return ff_neterror();
if (s->timeout < 0 && h->rw_timeout)
s->timeout = h->rw_timeout / 1000;
@@ -113,7 +113,7 @@ static int unix_read(URLContext *h, uint8_t *buf, int size)
ret = recv(s->fd, buf, size, 0);
if (!ret && s->type == SOCK_STREAM)
return AVERROR_EOF;
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int unix_write(URLContext *h, const uint8_t *buf, int size)
@@ -127,7 +127,7 @@ static int unix_write(URLContext *h, const uint8_t *buf, int size)
return ret;
}
ret = send(s->fd, buf, size, MSG_NOSIGNAL);
- return ret < 0 ? ff_neterrno() : ret;
+ return ret < 0 ? ff_neterror() : ret;
}
static int unix_close(URLContext *h)
diff --git a/libavformat/url.h b/libavformat/url.h
index 0784d77b64..a6b48d06d9 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -150,7 +150,7 @@ int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags,
*
* @param s server context
* @param c client context, must be unallocated.
- * @return >= 0 on success, ff_neterrno() on failure.
+ * @return >= 0 on success, ff_neterror() on failure.
*/
int ffurl_accept(URLContext *s, URLContext **c);
--
2.43.0
More information about the ffmpeg-devel
mailing list