Hi,
getsockopt(2) and setsockopt(2) take a void pointer for the third
parameter so there is no need for any of these casts.
I can do other style(9)-type cleanup in a subsequent diff or I can
cook this diff and do it all in one.
Thoughts, preferences?
Index: share/man/man4/multicast.4
===================================================================
RCS file: /cvs/src/share/man/man4/multicast.4,v
retrieving revision 1.12
diff -u -p -r1.12 multicast.4
--- share/man/man4/multicast.4 7 Mar 2018 09:54:23 -0000 1.12
+++ share/man/man4/multicast.4 19 Oct 2018 00:48:31 -0000
@@ -138,17 +138,17 @@ or disable multicast forwarding in the k
.Bd -literal -offset 5n
/* IPv4 */
int v = 1; /* 1 to enable, or 0 to disable */
-setsockopt(mrouter_s4, IPPROTO_IP, MRT_INIT, (void *)&v, sizeof(v));
+setsockopt(mrouter_s4, IPPROTO_IP, MRT_INIT, &v, sizeof(v));
.Ed
.Bd -literal -offset 5n
/* IPv6 */
int v = 1; /* 1 to enable, or 0 to disable */
-setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_INIT, (void *)&v, sizeof(v));
+setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_INIT, &v, sizeof(v));
\&...
/* If necessary, filter all ICMPv6 messages */
struct icmp6_filter filter;
ICMP6_FILTER_SETBLOCKALL(&filter);
-setsockopt(mrouter_s6, IPPROTO_ICMPV6, ICMP6_FILTER, (void *)&filter,
+setsockopt(mrouter_s6, IPPROTO_ICMPV6, ICMP6_FILTER, &filter,
sizeof(filter));
.Ed
.Pp
@@ -168,7 +168,7 @@ memcpy(&vc.vifc_lcl_addr, &vif_local_add
if (vc.vifc_flags & VIFF_TUNNEL)
memcpy(&vc.vifc_rmt_addr, &vif_remote_address,
sizeof(vc.vifc_rmt_addr));
-setsockopt(mrouter_s4, IPPROTO_IP, MRT_ADD_VIF, (void *)&vc,
+setsockopt(mrouter_s4, IPPROTO_IP, MRT_ADD_VIF, &vc,
sizeof(vc));
.Ed
.Pp
@@ -205,7 +205,7 @@ memset(&mc, 0, sizeof(mc));
mc.mif6c_mifi = mif_index;
mc.mif6c_flags = mif_flags;
mc.mif6c_pifi = pif_index;
-setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_ADD_MIF, (void *)&mc,
+setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_ADD_MIF, &mc,
sizeof(mc));
.Ed
.Pp
@@ -226,13 +226,13 @@ A multicast interface is deleted by:
.Bd -literal -offset indent
/* IPv4 */
vifi_t vifi = vif_index;
-setsockopt(mrouter_s4, IPPROTO_IP, MRT_DEL_VIF, (void *)&vifi,
+setsockopt(mrouter_s4, IPPROTO_IP, MRT_DEL_VIF, &vifi,
sizeof(vifi));
.Ed
.Bd -literal -offset indent
/* IPv6 */
mifi_t mifi = mif_index;
-setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_DEL_MIF, (void *)&mifi,
+setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_DEL_MIF, &mifi,
sizeof(mifi));
.Ed
.Pp
@@ -302,7 +302,7 @@ mc.mfcc_parent = iif_index;
for (i = 0; i < maxvifs; i++)
mc.mfcc_ttls[i] = oifs_ttl[i];
setsockopt(mrouter_s4, IPPROTO_IP, MRT_ADD_MFC,
- (void *)&mc, sizeof(mc));
+ &mc, sizeof(mc));
.Ed
.Bd -literal -offset indent
/* IPv6 */
@@ -315,7 +315,7 @@ for (i = 0; i < maxvifs; i++)
if (oifs_ttl[i] > 0)
IF_SET(i, &mc.mf6cc_ifset);
setsockopt(mrouter_s4, IPPROTO_IPV6, MRT6_ADD_MFC,
- (void *)&mc, sizeof(mc));
+ &mc, sizeof(mc));
.Ed
.Pp
The
@@ -345,7 +345,7 @@ memset(&mc, 0, sizeof(mc));
memcpy(&mc.mfcc_origin, &source_addr, sizeof(mc.mfcc_origin));
memcpy(&mc.mfcc_mcastgrp, &group_addr, sizeof(mc.mfcc_mcastgrp));
setsockopt(mrouter_s4, IPPROTO_IP, MRT_DEL_MFC,
- (void *)&mc, sizeof(mc));
+ &mc, sizeof(mc));
.Ed
.Bd -literal -offset indent
/* IPv6 */
@@ -354,7 +354,7 @@ memset(&mc, 0, sizeof(mc));
memcpy(&mc.mf6cc_origin, &source_addr, sizeof(mc.mf6cc_origin));
memcpy(&mc.mf6cc_mcastgrp, &group_addr, sizeof(mf6cc_mcastgrp));
setsockopt(mrouter_s4, IPPROTO_IPV6, MRT6_DEL_MFC,
- (void *)&mc, sizeof(mc));
+ &mc, sizeof(mc));
.Ed
.Pp
The following method can be used to get various statistics per
@@ -453,7 +453,7 @@ and
An example:
.Bd -literal -offset 3n
uint32_t v;
-getsockopt(sock, IPPROTO_IP, MRT_API_SUPPORT, (void *)&v, sizeof(v));
+getsockopt(sock, IPPROTO_IP, MRT_API_SUPPORT, &v, sizeof(v));
.Ed
.Pp
This would set
@@ -478,7 +478,7 @@ would fail.
To modify the API, and to set some specific feature in the kernel, then:
.Bd -literal -offset 3n
uint32_t v = MRT_MFC_FLAGS_DISABLE_WRONGVIF;
-if (setsockopt(sock, IPPROTO_IP, MRT_API_CONFIG, (void *)&v, sizeof(v))
+if (setsockopt(sock, IPPROTO_IP, MRT_API_CONFIG, &v, sizeof(v))
!= 0) {
return (ERROR);
}
@@ -498,7 +498,7 @@ The return value in
is the actual (sub)set of features that were enabled in the kernel.
To obtain later the same set of features that were enabled, use:
.Bd -literal -offset indent
-getsockopt(sock, IPPROTO_IP, MRT_API_CONFIG, (void *)&v, sizeof(v));
+getsockopt(sock, IPPROTO_IP, MRT_API_CONFIG, &v, sizeof(v));
.Ed
.Pp
The set of enabled features is global.
@@ -775,7 +775,7 @@ do {
return (ERROR);
} while (0);
setsockopt(mrouter_s4, IPPROTO_IP, MRT_ADD_BW_UPCALL,
- (void *)&bw_upcall, sizeof(bw_upcall));
+ &bw_upcall, sizeof(bw_upcall));
.Ed
.Pp
To delete a single filter, use