From 7dbef001355eafe02843066d616932370a354a18 Mon Sep 17 00:00:00 2001 From: Michael Ortmann Date: Wed, 4 Oct 2023 14:31:38 +0200 Subject: [PATCH 1/2] Enhance error msg and remove superfluous semicolon --- src/net.c | 2 +- src/tcldcc.c | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/net.c b/src/net.c index b5dbd04e9..6f2488a72 100644 --- a/src/net.c +++ b/src/net.c @@ -130,7 +130,7 @@ char *iptostr(struct sockaddr *sa) */ int setsockname(sockname_t *addr, char *src, int port, int allowres) { - char *endptr, *src2 = src;; + char *endptr, *src2 = src; long val; IP ip; volatile int af = AF_UNSPEC; diff --git a/src/tcldcc.c b/src/tcldcc.c index 6a704de87..1cd24019f 100644 --- a/src/tcldcc.c +++ b/src/tcldcc.c @@ -1176,15 +1176,22 @@ static int setlisten(Tcl_Interp *irp, char *ip, char *portp, char *type, char *m if (strlen(newip)) { setsockname(&name, newip, port, 1); i = open_address_listen(&name); + if (i < 0) { + snprintf(msg, sizeof msg, "Couldn't listen on port %d on the given " + "address '%s': %s. Please check that the port is not already in use", + realport, newip, strerror(errno)); + Tcl_AppendResult(irp, msg, NULL); + return TCL_ERROR; + } } else { i = open_listen(&port); - } - if (i < 0) { - egg_snprintf(msg, sizeof msg, "Couldn't listen on port '%d' on the given " + if (i < 0) { + snprintf(msg, sizeof msg, "Couldn't listen on port %d on the given " "address: %s. Please check that the port is not already in use", realport, strerror(errno)); - Tcl_AppendResult(irp, msg, NULL); - return TCL_ERROR; + Tcl_AppendResult(irp, msg, NULL); + return TCL_ERROR; + } } idx = new_dcc(&DCC_TELNET, 0); dcc[idx].sockname.addrlen = sizeof(dcc[idx].sockname.addr); From 3c570a95cf42ef20565fddb305972a9176dcd2ed Mon Sep 17 00:00:00 2001 From: Geo Date: Tue, 30 Jul 2024 12:37:45 -0400 Subject: [PATCH 2/2] Modify wording of message --- src/tcldcc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tcldcc.c b/src/tcldcc.c index 1cd24019f..48fa45f45 100644 --- a/src/tcldcc.c +++ b/src/tcldcc.c @@ -1177,8 +1177,8 @@ static int setlisten(Tcl_Interp *irp, char *ip, char *portp, char *type, char *m setsockname(&name, newip, port, 1); i = open_address_listen(&name); if (i < 0) { - snprintf(msg, sizeof msg, "Couldn't listen on port %d on the given " - "address '%s': %s. Please check that the port is not already in use", + snprintf(msg, sizeof msg, "Couldn't listen on port %d on %s: %s. " + "Please check that the port is not already in use", realport, newip, strerror(errno)); Tcl_AppendResult(irp, msg, NULL); return TCL_ERROR;