[Openvpn-devel,v2] Silence remaining cppcheck warnings on macOS and FreeBSD
Commit Message
From: Arne Schwabe <arne@rfc2549.org>
Change-Id: I571e30bb22ec7bffc2c5fa04fdcd73b52ce47e5e
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2108
---
This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2108
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <frank@lichtenheld.com>
@@ -3331,7 +3331,6 @@
int rtm_addrs;
struct sockaddr so_dst, so_mask;
char *cp = m_rtmsg.m_space;
- struct sockaddr *gate = NULL, *ifp = NULL, *sa;
struct rt_msghdr *rtm_aux;
#define rtm m_rtmsg.m_rtm
@@ -3396,6 +3395,8 @@
sockfd = -1;
/* extract return data from routing socket */
+ const struct sockaddr_in *gate = NULL;
+ const struct sockaddr_dl *adl = NULL;
rtm_aux = &rtm;
cp = (char *)(rtm_aux + 1);
if (rtm_aux->rtm_addrs)
@@ -3404,14 +3405,14 @@
{
if (i & rtm_aux->rtm_addrs)
{
- sa = (struct sockaddr *)cp;
+ const struct sockaddr *sa = (const struct sockaddr *)cp;
if (i == RTA_GATEWAY)
{
- gate = sa;
+ gate = (const struct sockaddr_in *)sa;
}
else if (i == RTA_IFP)
{
- ifp = sa;
+ adl = (const struct sockaddr_dl *)sa;
}
ADVANCE(cp, sa);
}
@@ -3423,19 +3424,18 @@
}
/* get gateway addr and interface name */
- if (gate != NULL)
+ if (gate)
{
/* get default gateway addr */
- rgi->gateway.addr = ntohl(((struct sockaddr_in *)gate)->sin_addr.s_addr);
+ rgi->gateway.addr = ntohl((gate)->sin_addr.s_addr);
if (rgi->gateway.addr)
{
rgi->flags |= RGI_ADDR_DEFINED;
}
- if (ifp)
+ if (adl)
{
/* get interface name */
- const struct sockaddr_dl *adl = (struct sockaddr_dl *)ifp;
if (adl->sdl_nlen && adl->sdl_nlen < sizeof(rgi->iface))
{
memcpy(rgi->iface, adl->sdl_data, adl->sdl_nlen);
@@ -1040,7 +1040,7 @@
* @param ctx the networking API opaque context
*/
static void
-do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu, const struct env_set *es,
+do_ifconfig_ipv6(const struct tuntap *tt, const char *ifname, int tun_mtu, const struct env_set *es,
openvpn_net_ctx_t *ctx)
{
#if !defined(TARGET_LINUX)
@@ -1231,7 +1231,7 @@
* @param ctx the networking API opaque context
*/
static void
-do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu, const struct env_set *es,
+do_ifconfig_ipv4(const struct tuntap *tt, const char *ifname, int tun_mtu, const struct env_set *es,
openvpn_net_ctx_t *ctx)
{
#if !defined(_WIN32) && !defined(TARGET_ANDROID)
@@ -1587,7 +1587,7 @@
}
static void
-undo_ifconfig_ipv4(const struct tuntap *tt, openvpn_net_ctx_t *ctx)
+undo_ifconfig_ipv4(const struct tuntap *tt, const openvpn_net_ctx_t *ctx)
{
#if defined(TARGET_LINUX)
int netbits = netmask_to_netbits2(tt->remote_netmask);
@@ -1622,7 +1622,7 @@
}
static void
-undo_ifconfig_ipv6(const struct tuntap *tt, openvpn_net_ctx_t *ctx)
+undo_ifconfig_ipv6(const struct tuntap *tt, const openvpn_net_ctx_t *ctx)
{
#if defined(TARGET_LINUX)
if (net_addr_v6_del(ctx, tt->actual_name, &tt->local_ipv6, tt->netbits_ipv6) < 0)