From ee2916a56f6749cb17c3b0c32d72fcfcecd34f73 Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Wed, 13 Feb 2019 13:32:36 +0000 Subject: [PATCH] util: Don't log errno on bad server address From man inet_pton(3): inet_pton() returns 1 on success (network address was successfully converted). 0 is returned if src does not contain a character string representing a valid network address in the specified address family. If af does not contain a valid address family, -1 is returned and errno is set to EAFNOSUPPORT. We can assume that the return value is 1 or 0 (because af is set to AF_INET4 or AF_INET6), therefore errno will not be set. If a user attempts to bind a server using invalid network address the following error message will be shown: Bad server address: Success Which is not very clear, with this change the error message will look like this: Invalid server address "localhost". The address must be in IPv4 or IPv6 format. Signed-off-by: Radostin Stoyanov --- criu/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/criu/util.c b/criu/util.c index 9221863ca..21e027fd7 100644 --- a/criu/util.c +++ b/criu/util.c @@ -1250,7 +1250,8 @@ static int get_sockaddr_in(struct sockaddr_storage *addr, char *host, } else if (inet_pton(AF_INET6, host, &((struct sockaddr_in6 *)addr)->sin6_addr)) { addr->ss_family = AF_INET6; } else { - pr_perror("Bad server address"); + pr_err("Invalid server address \"%s\". " + "The address must be in IPv4 or IPv6 format.\n", host); return -1; }