[PATCH] restructure struct initialization aesthetically

Rich Felker dalias at aerifal.cx
Tue Jun 20 15:33:26 UTC 2006


On Tue, Jun 20, 2006 at 11:17:57AM -0400, Robert P. J. Day wrote:
> 
>   just to make a couple struct initializations easier to read.
> 
> rday
> diff -pru busybox/networking/interface.c busybox.new/networking/interface.c
> --- busybox/networking/interface.c	2006-06-20 11:14:13.000000000 -0400
> +++ busybox.new/networking/interface.c	2006-06-20 11:15:59.000000000 -0400
> @@ -126,13 +126,12 @@ static char *INET_sprint(struct sockaddr
>  }
>  
>  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
>  };

This contains a bug: sizeof(unsigned long) is incorrect for AF_INET
addresses. It should merely be 4. The former will break 64bit
platforms.

Rich




More information about the busybox mailing list