From 48584645fbe8ec869b0f7f54b26945aa2aa3c26d Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 9 May 2021 10:32:54 +0200 Subject: [PATCH] BUILD: http_fetch: address a few aliasing warnings with older compilers gcc-4.4 complains about aliasing in smp_fetch_url_port() and smp_fetch_url_ip() because the local addr variable is casted to sturct sockaddr_in before being checked. The family should be checked on the sockaddr_storage and we have a function to retrieve the port. The compiler still sees some warnings but these ones are OK now. --- src/http_fetch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/http_fetch.c b/src/http_fetch.c index 020b25fcf5..1f3fa4e0cd 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -710,7 +710,7 @@ static int smp_fetch_url_ip(const struct arg *args, struct sample *smp, const ch sl = http_get_stline(htx); url2sa(HTX_SL_REQ_UPTR(sl), HTX_SL_REQ_ULEN(sl), &addr, NULL); - if (((struct sockaddr_in *)&addr)->sin_family != AF_INET) + if (addr.ss_family != AF_INET) return 0; smp->data.type = SMP_T_IPV4; @@ -731,11 +731,11 @@ static int smp_fetch_url_port(const struct arg *args, struct sample *smp, const sl = http_get_stline(htx); url2sa(HTX_SL_REQ_UPTR(sl), HTX_SL_REQ_ULEN(sl), &addr, NULL); - if (((struct sockaddr_in *)&addr)->sin_family != AF_INET) + if (addr.ss_family != AF_INET) return 0; smp->data.type = SMP_T_SINT; - smp->data.u.sint = ntohs(((struct sockaddr_in *)&addr)->sin_port); + smp->data.u.sint = get_host_port(&addr); smp->flags = 0; return 1; } -- 2.47.3