[U-Boot] [PATCH 22/28] net: Fix net buffer initialization

Mike Frysinger vapier at gentoo.org
Fri Feb 3 13:37:12 CET 2012


On Thursday 19 January 2012 19:53:25 Joe Hershberger wrote:
> --- a/include/net.h
> +++ b/include/net.h
> 
> -extern int NetLoop(enum proto_t);
> +extern int	NetLoop(enum proto_t protocol);

explicit variable names are unnecessary when the type is self explanatory

> --- a/net/net.c
> +++ b/net/net.c
> 
> -static void NetInitLoop(enum proto_t protocol)
> +static void NetInitLoop(void)

this could prob do with a sep patch ...

> +void
> +NetInit(void)
> +{
> +	static int first_call = 1;
> +
> +	if (first_call) {
> +		/*
> +		 *	Setup packet buffers, aligned correctly.
> +		 */
> +		int i;
> +		NetTxPacket = &PktBuf[0] + (PKTALIGN - 1);
> +		NetTxPacket -= (ulong)NetTxPacket % PKTALIGN;
> +		for (i = 0; i < PKTBUFSRX; i++)
> +			NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN;
> +
> +		ArpInit();
> +
> +		/* Only need to setup buffer pointers once. */
> +		first_call = 0;
> +	}

it *seems* like it should be fine, but i worry what might be lurking.  guess 
we'll find out :P.

> @@ -627,6 +639,12 @@ NetSendUDPPacket
> 
> +	/* make sure the NetTxPacket is initialized (NetInit() was called) */
> +	if (NetTxPacket == NULL) {
> +		puts("*** ERROR: NetTxPacket buffer pointer is NULL!\n");
> +		return -1;
> +	}

why check here only (udp) ?  and why check at all ?  this should be an 
assert() in the comment netsendpacket entry point ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120203/f4e0a2a4/attachment.pgp>


More information about the U-Boot mailing list