Re: C99 initializers for domains

2017-03-01 Thread Alexander Bluhm
On Wed, Mar 01, 2017 at 01:40:58PM +0100, Martin Pieuchot wrote:
> I converted the declarations when I audited the existing 'dom_init'
> functions.

> +struct domain inet6domain = {
> +  .dom_family = AF_INET6,
> +  .dom_name = "internet6",
> +  .dom_protosw = (struct protosw *)inet6sw,
> +  .dom_protoswNPROTOSW = (struct protosw *)&inet6sw[nitems(inet6sw)],

We don't need the (struct protosw *) casts anymore since I have
merged struct ip6protosw into protosw.

OK bluhm@



Re: C99 initializers for domains

2017-03-01 Thread David Hill
OK

On Wed, Mar 01, 2017 at 01:40:58PM +0100, Martin Pieuchot wrote:
> I converted the declarations when I audited the existing 'dom_init'
> functions.
> 
> ok?
> 
> Index: kern/uipc_proto.c
> ===
> RCS file: /cvs/src/sys/kern/uipc_proto.c,v
> retrieving revision 1.12
> diff -u -p -r1.12 uipc_proto.c
> --- kern/uipc_proto.c 22 Feb 2017 19:34:42 -  1.12
> +++ kern/uipc_proto.c 1 Mar 2017 12:05:35 -
> @@ -37,9 +37,9 @@
>  #include 
>  #include 
>  #include 
> -#include  
> +#include 
>  #include 
> -
> +
>  #include 
>  
>  /*
> @@ -72,6 +72,11 @@ struct protosw unixsw[] = {
>  }
>  };
>  
> -struct domain unixdomain =
> -{ AF_LOCAL, "unix", 0, unp_externalize, unp_dispose,
> -  unixsw, &unixsw[nitems(unixsw)] };
> +struct domain unixdomain = {
> +  .dom_family = AF_LOCAL,
> +  .dom_name = "unix",
> +  .dom_externalize = unp_externalize,
> +  .dom_dispose = unp_dispose,
> +  .dom_protosw = unixsw,
> +  .dom_protoswNPROTOSW = &unixsw[nitems(unixsw)]
> +};
> Index: net/pfkey.c
> ===
> RCS file: /cvs/src/sys/net/pfkey.c,v
> retrieving revision 1.37
> diff -u -p -r1.37 pfkey.c
> --- net/pfkey.c   22 Feb 2017 19:34:42 -  1.37
> +++ net/pfkey.c   1 Mar 2017 12:11:31 -
> @@ -256,13 +256,9 @@ pfkey_usrreq(struct socket *socket, int 
>  }
>  
>  struct domain pfkeydomain = {
> - PF_KEY,
> - "PF_KEY",
> - pfkey_init, /* init */
> - NULL, /* externalize */
> - NULL, /* dispose */
> - NULL, /* protosw */
> - NULL, /* protoswNPROTOSW */
> +  .dom_family = PF_KEY,
> +  .dom_name = "PF_KEY",
> +  .dom_init = pfkey_init,
>  };
>  
>  static struct protosw pfkey_protosw_template = {
> Index: net/rtsock.c
> ===
> RCS file: /cvs/src/sys/net/rtsock.c,v
> retrieving revision 1.223
> diff -u -p -r1.223 rtsock.c
> --- net/rtsock.c  22 Feb 2017 19:34:42 -  1.223
> +++ net/rtsock.c  1 Mar 2017 12:33:46 -
> @@ -1666,6 +1666,10 @@ struct protosw routesw[] = {
>  }
>  };
>  
> -struct domain routedomain =
> -{ PF_ROUTE, "route", route_init, 0, 0,
> -  routesw, &routesw[nitems(routesw)] };
> +struct domain routedomain = {
> +  .dom_family = PF_ROUTE,
> +  .dom_name = "route",
> +  .dom_init = route_init,
> +  .dom_protosw = routesw,
> +  .dom_protoswNPROTOSW = &routesw[nitems(routesw)]
> +};
> Index: netinet/in_proto.c
> ===
> RCS file: /cvs/src/sys/netinet/in_proto.c,v
> retrieving revision 1.73
> diff -u -p -r1.73 in_proto.c
> --- netinet/in_proto.c22 Feb 2017 19:34:42 -  1.73
> +++ netinet/in_proto.c1 Mar 2017 12:07:53 -
> @@ -438,8 +438,12 @@ struct protosw inetsw[] = {
>  }
>  };
>  
> -struct domain inetdomain =
> -{ AF_INET, "internet", 0, 0, 0,
> -  inetsw, &inetsw[nitems(inetsw)],
> -  sizeof(struct sockaddr_in),
> -  offsetof(struct sockaddr_in, sin_addr), 32 };
> +struct domain inetdomain = {
> +  .dom_family = AF_INET,
> +  .dom_name = "internet",
> +  .dom_protosw = inetsw,
> +  .dom_protoswNPROTOSW = &inetsw[nitems(inetsw)],
> +  .dom_rtkeylen = sizeof(struct sockaddr_in),
> +  .dom_rtoffset = offsetof(struct sockaddr_in, sin_addr),
> +  .dom_maxplen = 32
> +};
> Index: netinet6/in6_proto.c
> ===
> RCS file: /cvs/src/sys/netinet6/in6_proto.c,v
> retrieving revision 1.89
> diff -u -p -r1.89 in6_proto.c
> --- netinet6/in6_proto.c  22 Feb 2017 19:34:42 -  1.89
> +++ netinet6/in6_proto.c  1 Mar 2017 12:10:23 -
> @@ -340,13 +340,17 @@ struct protosw inet6sw[] = {
>  }
>  };
>  
> -struct domain inet6domain =
> -{ AF_INET6, "internet6", 0, 0, 0,
> -  (struct protosw *)inet6sw,
> -  (struct protosw *)&inet6sw[nitems(inet6sw)],
> -  sizeof(struct sockaddr_in6),
> -  offsetof(struct sockaddr_in6, sin6_addr), 128,
> -  in6_domifattach, in6_domifdetach, };
> +struct domain inet6domain = {
> +  .dom_family = AF_INET6,
> +  .dom_name = "internet6",
> +  .dom_protosw = (struct protosw *)inet6sw,
> +  .dom_protoswNPROTOSW = (struct protosw *)&inet6sw[nitems(inet6sw)],
> +  .dom_rtkeylen = sizeof(struct sockaddr_in6),
> +  .dom_rtoffset = offsetof(struct sockaddr_in6, sin6_addr),
> +  .dom_maxplen = 128,
> +  .dom_ifattach = in6_domifattach,
> +  .dom_ifdetach = in6_domifdetach
> +};
>  
>  /*
>   * Internet configuration info
> Index: netmpls/mpls_proto.c
> ===
> RCS file: /cvs/src/sys/netmpls/mpls_proto.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 mpls_proto.c
> --- netmpls/mpls_proto.c  27 Feb 2017 19:16:56 -  1.15
> +++ netmpls/mpls_proto.c  1 Mar 2017 12:14:17 -
> @@ -46,9 +46,9 @@
>   * MPLS address family: needed for the rout