diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2024-06-17 11:55:04 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-06-21 15:32:44 +0200 |
commit | dba7f0f5cee06dcfc205b0284ba19c2651f594c4 (patch) | |
tree | 94e8aea617e0e611bdca363e301038b2c47fa129 /tcp.c | |
parent | 92a22fef93a528030669e357a32c19f143a2d3b5 (diff) | |
download | passt-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.tar passt-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.tar.gz passt-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.tar.bz2 passt-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.tar.lz passt-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.tar.xz passt-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.tar.zst passt-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.zip |
treewide: Replace strerror() calls
Now that we have logging functions embedding perror() functionality,
we can make _some_ calls more terse by using them. In many places,
the strerror() calls are still more convenient because, for example,
they are used in flow debugging functions, or because the return code
variable of interest is not 'errno'.
While at it, convert a few error messages from a scant perror style
to proper failure descriptions.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tcp.c')
-rw-r--r-- | tcp.c | 24 |
1 files changed, 8 insertions, 16 deletions
@@ -1553,19 +1553,15 @@ static void tcp_bind_outbound(const struct ctx *c, int s, sa_family_t af) .sin_addr = c->ip4.addr_out, }; - if (bind(s, (struct sockaddr *)&addr4, sizeof(addr4))) { - debug("Can't bind IPv4 TCP socket address: %s", - strerror(errno)); - } + if (bind(s, (struct sockaddr *)&addr4, sizeof(addr4))) + debug_perror("IPv4 TCP socket address bind"); } if (*c->ip4.ifname_out) { if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, c->ip4.ifname_out, - strlen(c->ip4.ifname_out))) { - debug("Can't bind IPv4 TCP socket to interface:" - " %s", strerror(errno)); - } + strlen(c->ip4.ifname_out))) + debug_perror("IPv4 TCP socket interface bind"); } } else if (af == AF_INET6) { if (!IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr_out)) { @@ -1575,19 +1571,15 @@ static void tcp_bind_outbound(const struct ctx *c, int s, sa_family_t af) .sin6_addr = c->ip6.addr_out, }; - if (bind(s, (struct sockaddr *)&addr6, sizeof(addr6))) { - debug("Can't bind IPv6 TCP socket address: %s", - strerror(errno)); - } + if (bind(s, (struct sockaddr *)&addr6, sizeof(addr6))) + debug_perror("IPv6 TCP socket address bind"); } if (*c->ip6.ifname_out) { if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, c->ip6.ifname_out, - strlen(c->ip6.ifname_out))) { - debug("Can't bind IPv6 TCP socket to interface:" - " %s", strerror(errno)); - } + strlen(c->ip6.ifname_out))) + debug_perror("IPv6 TCP socket interface bind"); } } } |