introducing designated initializers for structures
Robert P. J. Day
rpjday at mindspring.com
Sat May 20 04:29:32 PDT 2006
attached is an example of a change i'd like to start making, just so
it's more obvious what's being initialized in a structure.
i forget the initialization rule, though -- what happens with
members of statically-allocated structures in terms of their initial
values? will they be NULL or 0? or should every member field be
explicitly initialized?
rday
-------------- next part --------------
diff -pru busybox/networking/interface.c busybox.new/networking/interface.c
--- busybox/networking/interface.c 2006-05-19 19:59:51.000000000 -0400
+++ busybox.new/networking/interface.c 2006-05-20 07:21:49.000000000 -0400
@@ -188,12 +188,15 @@ static char *UNIX_sprint(struct sockaddr
static struct aftype unix_aftype = {
- "unix", "UNIX Domain", AF_UNIX, 0,
- UNIX_print, UNIX_sprint, NULL, NULL,
- NULL, NULL, NULL,
- -1,
- "/proc/net/unix"
-};
+ .name = "unix",
+ .title = "UNIX Domain",
+ .af = AF_UNIX,
+ .alen = 0,
+ .print = UNIX_print,
+ .sprint = UNIX_sprint,
+ .fd = -1,
+ .flag_file = "/proc/net/unix"
+} ;
#endif /* HAVE_AFUNIX */
#if HAVE_AFINET
@@ -317,13 +320,12 @@ static int INET_getnetmask(char *adr, st
#endif /* KEEP_UNUSED */
static struct aftype inet_aftype = {
- "inet", "DARPA Internet", AF_INET, sizeof(unsigned long),
- NULL /* UNUSED INET_print */ , INET_sprint,
- NULL /* UNUSED INET_input */ , NULL /* UNUSED INET_reserror */ ,
- NULL /*INET_rprint */ , NULL /*INET_rinput */ ,
- NULL /* UNUSED INET_getnetmask */ ,
- -1,
- NULL
+ .name = "inet",
+ .title = "DARPA Internet",
+ .af = AF_INET,
+ .alen = sizeof(unsigned long),
+ .sprint = INET_sprint,
+ .fd = -1
};
#endif /* HAVE_AFINET */
@@ -387,14 +389,13 @@ static int INET6_input(int type, char *b
#endif /* KEEP_UNUSED */
static struct aftype inet6_aftype = {
- "inet6", "IPv6", AF_INET6, sizeof(struct in6_addr),
- NULL /* UNUSED INET6_print */ , INET6_sprint,
- NULL /* UNUSED INET6_input */ , NULL /* UNUSED INET6_reserror */ ,
- NULL /*INET6_rprint */ , NULL /*INET6_rinput */ ,
- NULL /* UNUSED INET6_getnetmask */ ,
- -1,
- NULL
-};
+ .name = "inet6",
+ .title = "IPv6",
+ .af = AF_INET6,
+ .alen = sizeof(struct in6_addr),
+ .sprint = INET6_sprint,
+ .fd = -1
+} ;
#endif /* HAVE_AFINET6 */
More information about the busybox
mailing list