From 9fea4a3ca57009b93365cccd2f64568e84e9de37 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Thu, 24 Oct 2024 16:29:14 +0200 Subject: [PATCH] CLEANUP: tools: rely on address family to detect ABNS sockets Following previous commit, in str2sa_range(), make use of address' family which was just set to check if the socket is ABNS or not instead of relying on an extra boolean to save this info. --- src/tools.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/tools.c b/src/tools.c index a51a4ffdc5..ec36a9d942 100644 --- a/src/tools.c +++ b/src/tools.c @@ -982,7 +982,6 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int char *back, *str2; char *port1, *port2; int portl, porth, porta; - int abstract = 0; int new_fd = -1; enum proto_type proto_type = 0; // to shut gcc warning int ctrl_type = 0; // to shut gcc warning @@ -1035,12 +1034,10 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int if (strncmp(str2, "unix@", 5) == 0) { str2 += 5; - abstract = 0; ss.ss_family = AF_UNIX; } else if (strncmp(str2, "uxdg@", 5) == 0) { str2 += 5; - abstract = 0; ss.ss_family = AF_UNIX; proto_type = PROTO_TYPE_DGRAM; ctrl_type = SOCK_DGRAM; @@ -1048,14 +1045,12 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int } else if (strncmp(str2, "uxst@", 5) == 0) { str2 += 5; - abstract = 0; ss.ss_family = AF_UNIX; proto_type = PROTO_TYPE_STREAM; ctrl_type = SOCK_STREAM; } else if (strncmp(str2, "abns@", 5) == 0) { str2 += 5; - abstract = 1; ss.ss_family = AF_CUST_ABNS; } else if (strncmp(str2, "ip@", 3) == 0) { @@ -1228,6 +1223,10 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int int prefix_path_len; int max_path_len; int adr_len; + int abstract = 0; + + if (ss.ss_family == AF_CUST_ABNS) + abstract = 1; /* complete unix socket path name during startup or soft-restart is * ..