From 860cb228a9c936b1b5d8868b1df8af7af50f13bd Mon Sep 17 00:00:00 2001 From: Maksym Sobolyev Date: Fri, 1 Dec 2023 17:59:37 -0800 Subject: [PATCH] Small cleanups. --- modules/proto_sctp/sctp_server.c | 4 ++-- socket_info.c | 6 +++--- socket_info.h | 9 +++------ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/modules/proto_sctp/sctp_server.c b/modules/proto_sctp/sctp_server.c index 38168ace877..2b4c0fbc436 100644 --- a/modules/proto_sctp/sctp_server.c +++ b/modules/proto_sctp/sctp_server.c @@ -194,11 +194,11 @@ int proto_sctp_send(const struct socket_info *source, char *buf, unsigned len, { int n; int tolen; - struct sockaddr s = to->s; /* XXX Linux defines sctp_sendmsg without const */ + union sockaddr_union _to = *to; /* XXX Linux defines sctp_sendmsg without const */ tolen=sockaddru_len(*to); again: - n=sctp_sendmsg(source->socket, buf, len, &s, tolen, 0, 0, 0, 0, 0); + n=sctp_sendmsg(source->socket, buf, len, &_to.s, tolen, 0, 0, 0, 0, 0); #ifdef XL_DEBUG LM_INFO("send status: %d\n", n); #endif diff --git a/socket_info.c b/socket_info.c index 4a41c623259..93a7983ff90 100644 --- a/socket_info.c +++ b/socket_info.c @@ -426,7 +426,7 @@ int new_sock2list(struct socket_id *sid, struct socket_info_full** list) * WARNING: it only works with ipv6 addresses on FreeBSD * return: -1 on error, 0 on success */ -static int expand_interface(struct socket_info *si, struct socket_info_full** list) +static int expand_interface(const struct socket_info *si, struct socket_info_full** list) { int ret = -1; struct ip_addr addr; @@ -838,7 +838,7 @@ int fix_socket_list(struct socket_info_full **list) for (l=sif->next;l;){ next=l->next; si = &sif->socket_info; - struct socket_info *sl = &l->socket_info; + const struct socket_info *sl = &l->socket_info; if ((si->port_no==sl->port_no) && (si->address.af==sl->address.af) && (memcmp(si->address.u.addr, sl->address.u.addr, si->address.len) @@ -876,7 +876,7 @@ int fix_socket_list(struct socket_info_full **list) LM_WARN("removing entry %s:%s [%s]:%s\n", get_proto_name(si->proto), si->name.s, si->address_str.s, si->port_no_str.s); - l = si; + l = sif; sif=sif->next; sock_listrm(list, l); free_sock_info(l); diff --git a/socket_info.h b/socket_info.h index 4a869789e16..3decaaa5ab9 100644 --- a/socket_info.h +++ b/socket_info.h @@ -80,9 +80,6 @@ struct socket_info_full { struct socket_info_full* prev; }; -#define get_head_si(sifp) (&(sifp)->socket_info) -#define get_si_next(sifp) (&((sifp)->next->socket_info)) - #define get_socket_real_name(_s) \ (&(_s)->sock_str) @@ -162,9 +159,9 @@ const struct socket_info* find_si(const struct ip_addr* ip, unsigned short port, #define set_sip_defaults( _port, _proto) \ do { \ - if (_proto==PROTO_NONE) _proto = PROTO_UDP; \ + if ((_proto)==PROTO_NONE) (_proto) = PROTO_UDP; \ if (_port==0) { \ - if (_proto==PROTO_TLS) _port = SIPS_PORT; else\ + if ((_proto)==PROTO_TLS) _port = SIPS_PORT; else\ _port = SIP_PORT; \ } \ } while(0) @@ -608,7 +605,7 @@ static inline char* socket2str(const struct socket_info *sock, char *s, int *len #define get_sock_info_list(_proto) \ - ((_proto>=PROTO_FIRST && _proto=PROTO_FIRST && (_proto)