BUG/MINOR: config: Remove final '\n' in error messages
Because error messages are displayed with appending final '\n', it's
useless to add '\n' in the message.
This patch should be backported.
[CF: An extra curly bracket was removed. On 2.9-dev it was removed by the commit
65f18d65a ("BUG/MINOR: config: Lenient port configuration parsing"). But it
was not backported to 2.8. Thus to avoid compilation error, it must be
removed here]
(cherry picked from commit 3e83b0940c5fd215e72277d41b8e44c45099693d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit f175b6db7302f42ac5b941d7a941e64097cccc6d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 8edbb208a648ba9829827e85ddaac6b1a0953433)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/tools.c b/src/tools.c
index 746e0d0..bec0a73 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -956,12 +956,12 @@
str2 = back = env_expand(strdup(str));
if (str2 == NULL) {
- memprintf(err, "out of memory in '%s'\n", __FUNCTION__);
+ memprintf(err, "out of memory in '%s'", __FUNCTION__);
goto out;
}
if (!*str2) {
- memprintf(err, "'%s' resolves to an empty address (environment variable missing?)\n", str);
+ memprintf(err, "'%s' resolves to an empty address (environment variable missing?)", str);
goto out;
}
@@ -1080,14 +1080,14 @@
new_fd = strtol(str2, &endptr, 10);
if (!*str2 || new_fd < 0 || *endptr) {
- memprintf(err, "file descriptor '%s' is not a valid integer in '%s'\n", str2, str);
+ memprintf(err, "file descriptor '%s' is not a valid integer in '%s'", str2, str);
goto out;
}
/* just verify that it's a socket */
addr_len = sizeof(ss2);
if (getsockname(new_fd, (struct sockaddr *)&ss2, &addr_len) == -1) {
- memprintf(err, "cannot use file descriptor '%d' : %s.\n", new_fd, strerror(errno));
+ memprintf(err, "cannot use file descriptor '%d' : %s.", new_fd, strerror(errno));
goto out;
}
@@ -1099,7 +1099,7 @@
new_fd = strtol(str2, &endptr, 10);
if (!*str2 || new_fd < 0 || *endptr) {
- memprintf(err, "file descriptor '%s' is not a valid integer in '%s'\n", str2, str);
+ memprintf(err, "file descriptor '%s' is not a valid integer in '%s'", str2, str);
goto out;
}
@@ -1109,14 +1109,14 @@
addr_len = sizeof(ss);
if (getsockname(new_fd, (struct sockaddr *)&ss, &addr_len) == -1) {
- memprintf(err, "cannot use file descriptor '%d' : %s.\n", new_fd, strerror(errno));
+ memprintf(err, "cannot use file descriptor '%d' : %s.", new_fd, strerror(errno));
goto out;
}
addr_len = sizeof(type);
if (getsockopt(new_fd, SOL_SOCKET, SO_TYPE, &type, &addr_len) != 0 ||
(type == SOCK_STREAM) != (sock_type == SOCK_STREAM)) {
- memprintf(err, "socket on file descriptor '%d' is of the wrong type.\n", new_fd);
+ memprintf(err, "socket on file descriptor '%d' is of the wrong type.", new_fd);
goto out;
}
@@ -1125,7 +1125,7 @@
((struct sockaddr_in *)&ss)->sin_addr.s_addr = new_fd;
((struct sockaddr_in *)&ss)->sin_port = 0;
} else {
- memprintf(err, "a file descriptor is not acceptable here in '%s'\n", str);
+ memprintf(err, "a file descriptor is not acceptable here in '%s'", str);
goto out;
}
}
@@ -1144,7 +1144,7 @@
adr_len = strlen(str2);
if (adr_len > max_path_len) {
- memprintf(err, "socket path '%s' too long (max %d)\n", str, max_path_len);
+ memprintf(err, "socket path '%s' too long (max %d)", str, max_path_len);
goto out;
}
@@ -1235,7 +1235,7 @@
porta = porth;
}
else if (*port1) { /* other any unexpected char */
- memprintf(err, "invalid character '%c' in port number '%s' in '%s'\n", *port1, port1, str);
+ memprintf(err, "invalid character '%c' in port number '%s' in '%s'", *port1, port1, str);
goto out;
}
else if (opts & PA_O_PORT_MAND) {
@@ -1251,7 +1251,7 @@
if (str2ip2(str2, &ss, 0) == NULL) {
if ((!(opts & PA_O_RESOLVE) && !fqdn) ||
((opts & PA_O_RESOLVE) && str2ip2(str2, &ss, 1) == NULL)) {
- memprintf(err, "invalid address: '%s' in '%s'\n", str2, str);
+ memprintf(err, "invalid address: '%s' in '%s'", str2, str);
goto out;
}
@@ -1266,11 +1266,11 @@
}
if (ctrl_type == SOCK_STREAM && !(opts & PA_O_STREAM)) {
- memprintf(err, "stream-type socket not acceptable in '%s'\n", str);
+ memprintf(err, "stream-type socket not acceptable in '%s'", str);
goto out;
}
else if (ctrl_type == SOCK_DGRAM && !(opts & PA_O_DGRAM)) {
- memprintf(err, "dgram-type socket not acceptable in '%s'\n", str);
+ memprintf(err, "dgram-type socket not acceptable in '%s'", str);
goto out;
}