From ca3b221b96a4d621c75f1e62aea74d6d83cadcd8 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Wed, 24 Jun 2020 01:49:27 +0200 Subject: Add STRLEN constant macro --- shared/utils.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'shared') diff --git a/shared/utils.h b/shared/utils.h index 0fc1429..d0142b1 100644 --- a/shared/utils.h +++ b/shared/utils.h @@ -34,6 +34,8 @@ extern unsigned debug_mask; #endif #endif +#define STRLEN(x) (sizeof(""x"") - 1) + #include "list.h" #include "debug.h" #include "external.h" @@ -41,11 +43,11 @@ extern unsigned debug_mask; /* Length of longest DNS name = 253 + trailing dot */ #define FQDN_STR_LEN 254 -/* Length of longest port string = strlen("65535") */ -#define PORT_STR_LEN 5 +/* Length of longest port string */ +#define PORT_STR_LEN STRLEN("65535") -/* Length of longest address family string = strlen("AF_INETX") */ -#define AF_STR_LEN 8 +/* Length of longest address family string */ +#define AF_STR_LEN STRLEN("AF_INETX") /* Length of longest addrstr, format = "AF_INETX */ #define ADDRSTRLEN (AF_STR_LEN + 1 + INET6_ADDRSTRLEN + 1 + PORT_STR_LEN + 1) -- cgit v1.2.3