1
0
mirror of http://git.haproxy.org/git/haproxy.git/ synced 2025-03-03 10:01:27 +00:00

MINOR: tools: use const for read only pointers in ip{cmp,cpy}

In this patch we fix the prototype for ipcmp() and ipcpy() functions so
that input pointers that are used exclusively for reads are used as const
pointers. This way, the compiler can safely assume that those variables
won't be altered by the function.
This commit is contained in:
Aurelien DARRAGON 2023-11-13 14:12:04 +01:00 committed by Christopher Faulet
parent 683b2ae013
commit 24da4d3ee7
2 changed files with 4 additions and 4 deletions
include/haproxy
src

View File

@ -782,7 +782,7 @@ extern int v6tov4(struct in_addr *sin_addr, struct in6_addr *sin6_addr);
* 1 (false) if the addr is not the same in both
* -1 (unable) if one of the addr is not AF_INET*
*/
int ipcmp(struct sockaddr_storage *ss1, struct sockaddr_storage *ss2, int check_port);
int ipcmp(const struct sockaddr_storage *ss1, const struct sockaddr_storage *ss2, int check_port);
/* compare a struct sockaddr_storage to a struct net_addr and return :
* 0 (true) if <addr> is matching <net>
@ -795,7 +795,7 @@ int ipcmp2net(const struct sockaddr_storage *addr, const struct net_addr *net);
* the caller must clear <dest> before calling.
* Returns a pointer to the destination
*/
struct sockaddr_storage *ipcpy(struct sockaddr_storage *source, struct sockaddr_storage *dest);
struct sockaddr_storage *ipcpy(const struct sockaddr_storage *source, struct sockaddr_storage *dest);
char *human_time(int t, short hz_div);

View File

@ -3382,7 +3382,7 @@ int v6tov4(struct in_addr *sin_addr, struct in6_addr *sin6_addr)
* 1 (false) if the addr is not the same in both
* -1 (unable) if one of the addr is not AF_INET*
*/
int ipcmp(struct sockaddr_storage *ss1, struct sockaddr_storage *ss2, int check_port)
int ipcmp(const struct sockaddr_storage *ss1, const struct sockaddr_storage *ss2, int check_port)
{
if ((ss1->ss_family != AF_INET) && (ss1->ss_family != AF_INET6))
return -1;
@ -3450,7 +3450,7 @@ int ipcmp2net(const struct sockaddr_storage *addr, const struct net_addr *net)
* it is preserved, so that this function can be used to switch to another
* address family with no risk. Returns a pointer to the destination.
*/
struct sockaddr_storage *ipcpy(struct sockaddr_storage *source, struct sockaddr_storage *dest)
struct sockaddr_storage *ipcpy(const struct sockaddr_storage *source, struct sockaddr_storage *dest)
{
int prev_port;