On Thu, Oct 18, 2018 at 4:00 PM <[email protected]> wrote:
> getsockopt(2) and setsockopt(2) take a void pointer for the third
> parameter so there is no need for any of these casts.
>
Yep.
> 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?
>
I would prefer line-wrapping adjustment that's enabled by the deletion of
the casts be done in the same commit. Those to change, IMHO, called out
below.
> @@ -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));
>
Unwrap completely.
@@ -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));
>
Ditto
...
> @@ -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));
>
Ditto and the next three.
> setsockopt(mrouter_s4, IPPROTO_IPV6, MRT6_ADD_MFC,
> - (void *)&mc, sizeof(mc));
> + &mc, sizeof(mc));
>
...
> setsockopt(mrouter_s4, IPPROTO_IP, MRT_DEL_MFC,
> - (void *)&mc, sizeof(mc));
> + &mc, sizeof(mc));
...
> setsockopt(mrouter_s4, IPPROTO_IPV6, MRT6_DEL_MFC,
> - (void *)&mc, sizeof(mc));
> + &mc, sizeof(mc));
>
@@ -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) {
>
Unwrap the !=0{ line.