mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-26 16:51:29 +00:00
avformat/network: use av_err2str to simplify code
No need to explicitly specify the buffer here as it is only ever passed to av_log, so av_err2str can be used.
This commit is contained in:
parent
e7126d9648
commit
24711b00c6
@ -287,16 +287,14 @@ int ff_listen_connect(int fd, const struct sockaddr *addr,
|
||||
if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen))
|
||||
ret = AVUNERROR(ff_neterrno());
|
||||
if (ret != 0) {
|
||||
char errbuf[100];
|
||||
ret = AVERROR(ret);
|
||||
av_strerror(ret, errbuf, sizeof(errbuf));
|
||||
if (will_try_next)
|
||||
av_log(h, AV_LOG_WARNING,
|
||||
"Connection to %s failed (%s), trying next address\n",
|
||||
h->filename, errbuf);
|
||||
h->filename, av_err2str(ret));
|
||||
else
|
||||
av_log(h, AV_LOG_ERROR, "Connection to %s failed: %s\n",
|
||||
h->filename, errbuf);
|
||||
h->filename, av_err2str(ret));
|
||||
}
|
||||
default:
|
||||
return ret;
|
||||
@ -421,7 +419,7 @@ int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address,
|
||||
int64_t next_attempt_us = av_gettime_relative(), next_deadline_us;
|
||||
int last_err = AVERROR(EIO);
|
||||
socklen_t optlen;
|
||||
char errbuf[100], hostbuf[100], portbuf[20];
|
||||
char hostbuf[100], portbuf[20];
|
||||
|
||||
if (parallel > FF_ARRAY_ELEMS(attempts))
|
||||
parallel = FF_ARRAY_ELEMS(attempts);
|
||||
@ -445,9 +443,8 @@ int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address,
|
||||
timeout_ms_per_address, h,
|
||||
customize_fd, customize_ctx);
|
||||
if (last_err < 0) {
|
||||
av_strerror(last_err, errbuf, sizeof(errbuf));
|
||||
av_log(h, AV_LOG_VERBOSE, "Connected attempt failed: %s\n",
|
||||
errbuf);
|
||||
av_err2str(last_err));
|
||||
continue;
|
||||
}
|
||||
if (last_err > 0) {
|
||||
@ -511,9 +508,8 @@ int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address,
|
||||
getnameinfo(attempts[i].addr->ai_addr, attempts[i].addr->ai_addrlen,
|
||||
hostbuf, sizeof(hostbuf), portbuf, sizeof(portbuf),
|
||||
NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
av_strerror(last_err, errbuf, sizeof(errbuf));
|
||||
av_log(h, AV_LOG_VERBOSE, "Connection attempt to %s port %s "
|
||||
"failed: %s\n", hostbuf, portbuf, errbuf);
|
||||
"failed: %s\n", hostbuf, portbuf, av_err2str(last_err));
|
||||
closesocket(attempts[i].fd);
|
||||
memmove(&attempts[i], &attempts[i + 1],
|
||||
(nb_attempts - i - 1) * sizeof(*attempts));
|
||||
@ -528,9 +524,8 @@ int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address,
|
||||
if (last_err >= 0)
|
||||
last_err = AVERROR(ECONNREFUSED);
|
||||
if (last_err != AVERROR_EXIT) {
|
||||
av_strerror(last_err, errbuf, sizeof(errbuf));
|
||||
av_log(h, AV_LOG_ERROR, "Connection to %s failed: %s\n",
|
||||
h->filename, errbuf);
|
||||
h->filename, av_err2str(last_err));
|
||||
}
|
||||
return last_err;
|
||||
}
|
||||
@ -591,7 +586,5 @@ 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_log(ctx, level, "%s: %s\n", prefix, errbuf);
|
||||
av_log(ctx, level, "%s: %s\n", prefix, av_err2str(ff_neterrno()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user