recv_pattern(): Improve error diagnostics.
[paraslash.git] / net.c
diff --git a/net.c b/net.c
index b3588f6d9e3d43d62f592a982b11f0db5f1e550b..00844d735c033e73a20b8a975e0bf9db142d2600 100644 (file)
--- a/net.c
+++ b/net.c
@@ -88,7 +88,8 @@ static bool is_v4_dot_quad(const char *address)
        bool result;
        regex_t r;
 
-       assert(!regcomp(&r, "^([0-9]+\\.){3}[0-9]+$", REG_EXTENDED|REG_NOSUB));
+       assert(para_regcomp(&r, "^([0-9]+\\.){3}[0-9]+$",
+               REG_EXTENDED | REG_NOSUB) >= 0);
        result = regexec(&r, address, 0, NULL, 0) == 0;
        regfree(&r);
        return result;
@@ -837,10 +838,11 @@ int recv_pattern(int fd, const char *pattern, size_t bufsize)
        ret = 1;
 out:
        if (ret < 0) {
-               PARA_NOTICE_LOG("n = %d, did not receive pattern '%s'\n", n,
-                       pattern);
+               PARA_NOTICE_LOG("did not receive pattern '%s'\n", pattern);
                if (n > 0)
-                       PARA_NOTICE_LOG("recvd: %s\n", buf);
+                       PARA_NOTICE_LOG("recvd %d bytes: %s\n", n, buf);
+               else if (n < 0)
+                       PARA_NOTICE_LOG("%s\n", para_strerror(-n));
        }
        free(buf);
        return ret;