mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
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.
This commit is contained in:
parent
b2475a139e
commit
48584645fb
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user